text:
Q: why storyboard ui elements not showing on UIViewController in xcode 6? I am new to IOS development. I am developing an app for IOS 8 devices. I used storyboard for my design yesterday my storyboard showing all UI design but today morning it show blank UIViewController no UI element vision please see in screen shot and very strange thing is that when i run my app all ui element visible in my device. I google but dont find any solution please help me out. Thank you in advance.

A: I have the same issue while copy a ViewController to another storyboard.
Fixed by following steps:
1: Select the viewController
2: Click on 5th Tab
3: Set the simulated size to Fixed.

A:
Select install:
Since all components [like label,textfield,buttons] are in disable mode, one select Installed check mark its will be enable again adjust constrain accordingly.

A: It looks to me like you are using size class and you went into a particular size class and added these views. Now you are back in Any size class, so the views are not there (that is why they are greyed out in the document outline at the left). They are available only for that particular size class. If you switch back to it again, whatever it was, you will see them again. Basically, you have created conditional views - the condition being that they are present only when that particular size class situation is the case.
In other words, if you want your layout to apply in the general case, you want to start by creating and editing it under Any size classes. Only then do you switch to a particular size class and modify the layout for that particular size class.

when i run my app all ui element visible in my device

Yes, because on your device the particular size class situation matches the size class you were editing when you added those views. So there they are. That seems to me to prove my guess is right.

A: The size must be the same, in all xcode storyboard

A: In my case, it was due to me setting alpha to 0.0 and forgetting it.


text:
Q: Почему singleton плохо, а share из DI контейнеров, которые по сути тоже создают singleton - это хороший паттерн? Почему singleton плохо, а share из DI контейнеров, которые по сути тоже создают singleton - это хороший паттерн?
И В чем отличие?

A: Хороший вопрос.
На самом деле share из DI контейнеров тоже плохо.
И большинство нормальных фреймворков уходят от работы с контейнером напрямую. В Симфони в контроллере получишь не контейнер, а фигу.
Потому что все зависимости класса должны передаваться в качестве аргументов в конструктор. И в итоге контейнер используется только при автоматическом создании классов, чтобы было откуда брать экземпляры классов-зависимостей.

A: На мой взгляд вся пропаганда о том, что синглтон плох - это для начинающих разработчиков, которых остерегают от того, чтобы они везде их не напихали, и чтобы их потом за это не уволили.
И.М.Х.О. Синглтон надо уметь применять к месту. Вот и всё.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Why don't definition lists work on SE? From Allowed HTML Tags, I find SE supports

, so I copied an example from W3schools:

Coffee

Black hot drink

Milk

White cold drink

And it seems...normal.

Coffee
Black hot drink
MilkWhite cold drink

What's going on?

A: They "work" just fine: if you open up your browser's DOM inspector, you'll see the text marked up just as you wrote it.
But there's no styling for definition lists. So they look just like normal text.
See: Better style for HTML 'definition list'
 elements


text:
Q: How to indicate in php 7.1 that the return type is the current child type? I have
abstract class A{
  public static function getSingle($where = []) {
    $classname = get_called_class();

    $record =     static::turnTheWhereIntoArecordFromDB($where);
    $model = new  $classname($record);
    return $model;
  }
}

class B extends A{

}

$x = B::getSingle();

$x has no type hinting... I like type hinting, so I want type hinting for B, not for A
How to enable type hinting directly for $x?
what I thought is something like
 public function getSingle($where = []) : ?get_called_class()

This obviously doesn't work
Is there something that does?

A: For the example you present, why do you need to have a factory method? You are creating a new instance from the constructor, why don't you just $x = new B($record)!
UPDATED ABOVE

abstract class A
{
    /**
     * @param array $where
     * @return static
     */
    public static function getSingle($where = [])
    {
        $classname = get_called_class();

        $model = new  $classname($record);
        return $model;
    }
}

@return static will type hinting its child class. Also I changed your function to static function, it is typical factory pattern.

A: Add @method B getSingle to the B class phpdoc.
/**
* Class B
* @method B getSingle
*/
class B extends A{

}

https://docs.phpdoc.org/references/phpdoc/tags/method.html

A: I know that you specify PHP 7.1, but starting with PHP 8 (to be released on November 2020) this will be possible with the addition of the static return type hint.
The RFC was approved unanimously, 54-0.
This means you'll be able to do:
class Foo

   public static function build(): static
   {
        return new static();
   }
}

class Bar extends Foo {}

Additionally, no need to muck around with $classname = get_called_class(); new $classname();. You can simply do new static(), which is neater and has the same result.
And Bar::build() is type-hinted to indicate that it returns Bar and not Foo by virtue of late static binding.

A: Let the abstract class implement an interface and type hint that interface. The child does not have to implement the interface explicitly.
abstract class A implements BarInterface
  {
    public function foo (): BarInterface
      {
        return new static;
      }
  }


text:
Q: how to set 'arrange by' for all the folders in the finder In finder, we can 'arrange by' for each folder separately, but how to set these settings for all folders.
NOTE: i have tried 'Use as defaults' in info dialog but of no use

A: *

*Go to a folder that should be arranged by Name.

*Open "View Options" with ⌘+J.

*Select "Arrange by Name".

*Select "Use as Defaults" to make it default to all folders.

A: To answer your first question, this isn't a script, but it is a procedure you can follow to make all Finder windows sorted by name. Open a Finder window. Select a regular folder; not a pseudo-folder (the Use as defaults button does not appear on Airdrop or Recents). Press Command-J. In the Sort By drop-down control, select Name. Click the Use as defaults button at the bottom of the window.
For the second, no, "sort by" sorts everything, including folders. If there are particular files or folders you want at the top of the list, you could start their name with a space, but don't do that to folders that applications or the system expect to have particular names. It does work for folders you create within your own Documents directory, however.

A: You can use TotalFinder to do this.

A: Unfortunately, I don't know of any scripts that can arrange all files in EVERY folder by name, or scripts to keep the folders at the top, but you can sort your files by type (extensions, alphabetically), and by name through right clicking (Control-click) in your folder (not selecting any specific file), and select Clean up by -> Kind or Name.


text:
Q: Better solution than left join subqueries? TablePatient.Patient_ID(PK)

TableProviders.Encounter (joins to PK)

TableProviders.Provider_Type

TableProviders.Provider_ID

TableNames.Full_Name

TableNames.Provider_ID (joins to Table Names)

I want a query that will give, for all the Patient_IDs, the Full_Name of the provider for every Provider ID.
There are about 30 provider_types.
I have made this already using a left join a ton of left joins.  It takes a long time to run and I am thinking there is a trick I am missing.
Any help?

A: If I understand what you mean, you just want to group the answer by Patient Id and then Provider ID. A full name is unique on a provider id right ?
This should be something like
SELECT TablePatient.Patient_ID,
TableProviders.Provider_ID,
TableNames.Full_Name

FROM TablePatient LEFT JOIN
TableProviders on TablePatient.Patient_ID = TableProviders.Encounter
LEFT JOIN
TableNames on TableNames.Provider_ID = TablerProviders.Provider_ID

group by TablePatient.Patient_ID,
TableProviders.Provider_ID,
TableNames.Full_Name

You can either group by TableNames.Full_Name or  select First(TableNames.Full_Name) for example if indeed a full name is unique to a provider ID.
Note : I used the SQL server Syntax, there can be différences with Oracle ..

A: Ok, my previous answer didn't match at all what you meant. You want to pivot the table to have on each line one Patient_ID with every Full_name for every provider_type. I assume that each patient has only one provider for one type and not more ; if more, you will have more than one row for each patient, and anyway I don't think it's really possible.
Here is my solution with pivot. The first part is to make it more understandable, so I create a table named TABLE_PATIENT in a subquery.
WITH TABLE_PATIENT AS
(
SELECT TablePatient.Patient_ID,
TableProviders.Provider_Type,
TableNames.Full_Name

FROM TablePatient LEFT JOIN
TableProviders on TablePatient.Patient_ID = TableProviders.Encounter
LEFT JOIN
TableNames on TableNames.Provider_ID = TableProviders.Provider_ID

group by TablePatient.Patient_ID,
TableProviders.Provider_Type,
TableNames.Full_Name
)

SELECT *
FROM TABLE_PATIENT
PIVOT
(
    min(Full_name)
    for Provider_type in ([type1], [type2],[type3])
) AS PVT

So TABLE_PATIENT just has many rows for each patient, with one provider each row, and the pivot puts everything on a single row. Tell me if something doesn't work.
You need to write every type you want in the [type1],[type2] etc. Just put them inside [], no other character needed as ' or anything else.
If you put only some types, then the query will not show providers of other types.
Tell me if something doesn't work.


text:
Q: Automatically adjust width of a view based NSTableView based on content Title should read: Automatically adjust width of the containing NSWindow of a view based NSTableView based on NSTableCellView's NSTextField content intrinsic content size.
A bit like this other question, I would like to implement an autocompletion NSWindow with an NSTableView inside it that adjust to the width of the length of the available autocompletions implemented as NSTextField inside an NSTableCellView. Each autocompletion should obviously be displayed on one line...
The previous question has been answered but was only related to the hight of the NSTableView. I would like to know how to do the "same" for the width. I would like to implement the solution as much as possible using auto layout.
I've tried to set the horizontal "Content Hugging Priority" and the "Content Compression Resistance Priority" to the maximum of 1000 for each view element participating in the final display of the NSWindow. I was thinking that the intrinsic content size of the NSTextField would force all other elements to adjust but it does not work.
Setting the NSTableColumn width does not work either since the NSClipView of the NSScrollView is not modified by this width: the NSScrollView adjusts and creates horizontal scroll bars to cover the entire "document".
Here is a link to a sample project to demonstrate the problem:
sample project
Any help would be greatly appreciated!

A: I fixed the problem using this code with the scrollViewWidthConstraint being an IBOutlet to the NSScrollView width constraint, localTableView being an IBOutlet to the NSTableView and tableColumn being an IBOutlet to the NSTableColumn (the only one in my case).
Note: The linked project on GitHub has been updated with the changes.
override func viewDidLoad() {

    super.viewDidLoad()

    self.updateTable()
}

func updateTable() {

    localTableView.reloadData()

    var computedWidth: CGFloat = 0

    for var row = 0; row < 10; row++  {

        let tableCellView = self.tableView(localTableView, viewForTableColumn: tableColumn, row: row) as! NSTableCellView

        computedWidth = max(computedWidth, tableCellView.textField!.intrinsicContentSize.width)
    }

    scrollViewWidthConstraint!.constant = computedWidth

    scrollView.needsUpdateConstraints = true
}


text:
Q: HTML5 Canvas blending & IE / Edge I'm working on a project that makes use of Canvas blending - of course, IE/Edge still don't support blending modes. Some simplified code (fiddle here) that shows the issue:
<canvas id="below" width="100" height="100"></canvas>
<canvas id="texture" width="100" height="100"></canvas>
<canvas id="composite" width="100" height="100" style="z-index:1x solid green;"></canvas>

var can = document.getElementById('below');
var below = can.getContext('2d');
below.fillStyle = "#FF0000";
below.fillRect(0,0,512,512);
var can2 = document.getElementById('texture');
var texture = can2.getContext('2d');

var img = new Image;
img.onload = function(){
    texture.drawImage(img,0,0);
    var can3 = document.getElementById('composite');
    var composite = can3.getContext('2d');
    composite.globalCompositeOperation = "multiply";
    composite.drawImage(can, 0, 0);
    composite.drawImage(can2, 0, 0);
};
img.src = "http://i.imgur.com/DGuWpEg.png";

I came across this thread which seems to have a workaround, but I'm not quite sure how to properly implement it.  Any pointers would be appreciated.

A: Stackoverflow member and contributor Phrogz has published a very nice library that uses context.getImageData to fetch + blend the pixel data from an image and then uses context.putImageData to apply blending to the image.
His library supports these compositing, coloring & blending modes:

*

*src-over

*screen

*multiply

*difference

*src-in

*plus

*add

*overlay

*hardlight

*colordodge

*dodge

*colorburn

*burn

*darken

*darker

*lighten

*lighter

*exclusion

*softlight

*luminosity

*color

*hue

*saturation

*lightercolor

*darkercolor

Phrogz's Blending library is available on GitHub:
https://github.com/Phrogz/context-blender
And since it's liberally licensed, below is a copy for Stackoverflow posterity:
Context Blender JavaScript Library
Copyright © 2010 Gavin Kistner
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
(function(){

var defaultOffsets = {
  destX   : 0,
  destY   : 0,
  sourceX : 0,
  sourceY : 0,
  width   : 'auto',
  height  : 'auto'
};

if (typeof require==='function' && typeof module==='object'){
  var canvas = require('canvas');
  addBlendMethod(canvas.Context2d.prototype);
  module.exports = canvas;
} else addBlendMethod(this.CanvasRenderingContext2D && this.CanvasRenderingContext2D.prototype);

function addBlendMethod(object){
  if (!object || typeof object.getImageData!=='function') return console.error("context blender called without a valid context prototype");
  Object.defineProperty(object,'blendOnto',{value:blendOnto});

  // For querying of functionality from other libraries
  var modes = blendOnto.supportedBlendModes = 'normal src-over screen multiply difference src-in plus add overlay hardlight colordodge dodge colorburn burn darken darker lighten lighter exclusion softlight luminosity color hue saturation lightercolor darkercolor'.split(' ');
  var supports = blendOnto.supports = {};
  for (var i=modes.length;i--;) supports[modes[i]] = true;
  blendOnto.aliases = { "src-over":"normal", plus:"add", dodge:"colordodge", burn:"colorburn", darker:"darken", lighter:"lighten" };
  return object;
}

function blendOnto(destContext,blendMode,offsetOptions){
    var offsets={};
    for (var key in defaultOffsets){
      if (defaultOffsets.hasOwnProperty(key)){
        offsets[key] = (offsetOptions && offsetOptions[key]) || defaultOffsets[key];
      }
    }
    if (offsets.width =='auto') offsets.width =this.canvas.width;
    if (offsets.height=='auto') offsets.height=this.canvas.height;
    offsets.width  = Math.min(offsets.width, this.canvas.width-offsets.sourceX, destContext.canvas.width-offsets.destX );
    offsets.height = Math.min(offsets.height,this.canvas.height-offsets.sourceY,destContext.canvas.height-offsets.destY);

    var srcD = this.getImageData(offsets.sourceX,offsets.sourceY,offsets.width,offsets.height);
    var dstD = destContext.getImageData(offsets.destX,offsets.destY,offsets.width,offsets.height);
    var src  = srcD.data;
    var dst  = dstD.data;
    var sA, dA, len=dst.length;
    var sRA, sGA, sBA, dRA, dGA, dBA, dA2,
        r1,g1,b1, r2,g2,b2;
    var demultiply;

    function Fsoftlight(a,b) {
      /*
        http://en.wikipedia.org/wiki/Blend_modes#Soft_Light
        2ab+a^2 (1-2b), if b<0.5
        2a(1-b) +sqrt(a)(2b-1), otherwise
      */
      var b2=b<<1;
      if (b<128) return (a*(b2+(a*(255-b2)>>8)))>>8;
      else       return (a*(511-b2)+(Math.sqrt(a<<8)*(b2-255)))>>8;
    }

    function Foverlay(a,b) {
      return a<128 ?
        (a*b)>>7 : // (2*a*b)>>8 :
        255 - (( (255 - b) * (255 - a))>>7);
    }

    function Fdodge(a,b) {
      return (b==255 && a==0) ? 255 : Math.min(255,(a<<8)/(255-b));
    }

    function Fburn(a,b) {
      return (b==255 && a==0) ? 0 : 255-Math.min(255,((255-a)<<8)/b);
    }

    /*
      // yyy = similar to YCbCr
      0.2990    0.5870    0.1140
      -0.1687   -0.3313    0.5000
      0.5000   -0.4187   -0.0813
    */
    function rgb2YCbCr(r,g,b) {
      return {
        r: 0.2990*r+0.5870*g+0.1140*b,
        g: -0.1687*r-0.3313*g+0.5000*b,
        b: 0.5000*r-0.4187*g-0.0813*b };
    }

    /*
      1.0000   -0.0000    1.4020
      1.0000   -0.3441   -0.7141
      1.0000    1.7720    0.0000
    */
    function YCbCr2rgb(r,g,b) {
      return {
        r: r +1.4020*b,
        g: r-0.3441*g   -0.7141*b,
        b: r+1.7720*g };
    }

    function rgb2hsv(r,g,b) {
      var c=rgb2YCbCr(r,g,b);
      var s=Math.sqrt(c.g*c.g+c.b*c.b),
          h=Math.atan2(c.g,c.b);
      return {h:h, s:s, v:c.r };
    }

    function hsv2rgb(h,s,v) {
      var g=s*Math.sin(h),
          b=s*Math.cos(h);
      return YCbCr2rgb(v,g,b);
    }

    for (var px=0;px<len;px+=4){
      sA  = src[px+3]/255;
      dA  = dst[px+3]/255;
      dA2 = (sA + dA - sA*dA);
      dst[px+3] = dA2*255;

      r1=dst[px], g1=dst[px+1], b1=dst[px+2];
      r2=src[px], g2=src[px+1], b2=src[px+2];

      sRA = r2/255*sA;
      dRA = r1/255*dA;
      sGA = g2/255*sA;
      dGA = g1/255*dA;
      sBA = b2/255*sA;
      dBA = b1/255*dA;

      demultiply = 255 / dA2;

      var f1=dA*sA, f2=dA-f1, f3=sA-f1;

      switch(blendMode){
        // ******* Very close match to Photoshop
        case 'normal':
        case 'src-over':
          dst[px  ] = (sRA + dRA - dRA*sA) * demultiply;
          dst[px+1] = (sGA + dGA - dGA*sA) * demultiply;
          dst[px+2] = (sBA + dBA - dBA*sA) * demultiply;
        break;

        case 'screen':
          dst[px  ] = (sRA + dRA - sRA*dRA) * demultiply;
          dst[px+1] = (sGA + dGA - sGA*dGA) * demultiply;
          dst[px+2] = (sBA + dBA - sBA*dBA) * demultiply;
        break;

        case 'multiply':
          dst[px  ] = (sRA*dRA + sRA*(1-dA) + dRA*(1-sA)) * demultiply;
          dst[px+1] = (sGA*dGA + sGA*(1-dA) + dGA*(1-sA)) * demultiply;
          dst[px+2] = (sBA*dBA + sBA*(1-dA) + dBA*(1-sA)) * demultiply;
        break;

        case 'difference':
          dst[px  ] = (sRA + dRA - 2 * Math.min( sRA*dA, dRA*sA )) * demultiply;
          dst[px+1] = (sGA + dGA - 2 * Math.min( sGA*dA, dGA*sA )) * demultiply;
          dst[px+2] = (sBA + dBA - 2 * Math.min( sBA*dA, dBA*sA )) * demultiply;
        break;

        // ******* Slightly different from Photoshop, where alpha is concerned
        case 'src-in':
          dA2 = sA*dA;
          demultiply = 255 / dA2;
          dst[px  ] = sRA*dA * demultiply;
          dst[px+1] = sGA*dA * demultiply;
          dst[px+2] = sBA*dA * demultiply;
          dst[px+3] = dA2*255;
        break;

        case 'plus':
        case 'add':
          // Photoshop doesn't simply add the alpha channels; this might be correct wrt SVG 1.2
          dst[px  ] = Math.min(sRA + dRA,1) * demultiply;
          dst[px+1] = Math.min(sGA + dGA,1) * demultiply;
          dst[px+2] = Math.min(sBA + dBA,1) * demultiply;
        break;

        case 'overlay':
          dst[px]   = f1*Foverlay(r1,r2) + f2*r1 + f3*r2;
          dst[px+1] = f1*Foverlay(g1,g2) + f2*g1 + f3*g2;
          dst[px+2] = f1*Foverlay(b1,b2) + f2*b1 + f3*b2;
        break;

        case 'hardlight': // hardlight(a,b) = overlay(b,a)
          dst[px]   = f1*Foverlay(r2,r1) + f2*r1 + f3*r2;
          dst[px+1] = f1*Foverlay(g2,g1) + f2*g1 + f3*g2;
          dst[px+2] = f1*Foverlay(b2,b1) + f2*b1 + f3*b2;
        break;

        case 'colordodge':
        case 'dodge':
          dst[px]   = f1*Fdodge(r1,r2) + f2*r1 + f3*r2;
          dst[px+1] = f1*Fdodge(g1,g2) + f2*g1 + f3*g2;
          dst[px+2] = f1*Fdodge(b1,b2) + f2*b1 + f3*b2;
        break;

        case 'colorburn':
        case 'burn':
          dst[px]   = f1*Fburn(r1,r2) + f2*r1 + f3*r2;
          dst[px+1] = f1*Fburn(g1,g2) + f2*g1 + f3*g2;
          dst[px+2] = f1*Fburn(b1,b2) + f2*b1 + f3*b2;
        break;

        case 'darken':
        case 'darker':
          dst[px]   = f1*(r1<r2 ? r1 : r2) + f2*r1 + f3*r2;
          dst[px+1] = f1*(g1<g2 ? g1 : g2) + f2*g1 + f3*g2;
          dst[px+2] = f1*(b1<b2 ? b1 : b2) + f2*b1 + f3*b2;
        break;

        case 'lighten':
        case 'lighter':
          dst[px  ] = (sRA<dRA ? dRA : sRA) * demultiply;
          dst[px+1] = (sGA<dGA ? dGA : sGA) * demultiply;
          dst[px+2] = (sBA<dBA ? dBA : sBA) * demultiply;
        break;

        case 'exclusion':
          dst[px  ] = (dRA+sRA - 2*dRA*sRA) * demultiply;
          dst[px+1] = (dGA+sGA - 2*dGA*sGA) * demultiply;
          dst[px+2] = (dBA+sBA - 2*dBA*sBA) * demultiply;
        break;

        case 'softlight':
          dst[px]   = f1*Fsoftlight(r1,r2) + f2*r1 + f3*r2;
          dst[px+1] = f1*Fsoftlight(g1,g2) + f2*g1 + f3*g2;
          dst[px+2] = f1*Fsoftlight(b1,b2) + f2*b1 + f3*b2;
        break;

        case 'luminosity':
          var hsl  = rgb2YCbCr(r1,g1,b1);
          var hsl2 = rgb2YCbCr(r2,g2,b2);
          var rgb=YCbCr2rgb(hsl2.r, hsl.g, hsl.b);
          dst[px]   = f1*rgb.r + f2*r1 + f3*r2;
          dst[px+1] = f1*rgb.g + f2*g1 + f3*g2;
          dst[px+2] = f1*rgb.b + f2*b1 + f3*b2;
        break;

        case 'color':
          var hsl  = rgb2YCbCr(r1,g1,b1);
          var hsl2 = rgb2YCbCr(r2,g2,b2);
          var rgb=YCbCr2rgb(hsl.r, hsl2.g, hsl2.b);
          dst[px]   = f1*rgb.r + f2*r1 + f3*r2;
          dst[px+1] = f1*rgb.g + f2*g1 + f3*g2;
          dst[px+2] = f1*rgb.b + f2*b1 + f3*b2;
        break;

        case 'hue':
          var hsl =rgb2hsv(r1,g1,b1);
          var hsl2=rgb2hsv(r2,g2,b2);
          var rgb=hsv2rgb(hsl2.h, hsl.s, hsl.v);
          dst[px]   = f1*rgb.r + f2*r1 + f3*r2;
          dst[px+1] = f1*rgb.g + f2*g1 + f3*g2;
          dst[px+2] = f1*rgb.b + f2*b1 + f3*b2;
        break;

        case 'saturation':
          var hsl =rgb2hsv(r1,g1,b1);
          var hsl2=rgb2hsv(r2,g2,b2);
          var rgb=hsv2rgb(hsl.h, hsl2.s, hsl.v);
          dst[px]   = f1*rgb.r + f2*r1 + f3*r2;
          dst[px+1] = f1*rgb.g + f2*g1 + f3*g2;
          dst[px+2] = f1*rgb.b + f2*b1 + f3*b2;
        break;

        case 'lightercolor':
          var rgb = 2.623*(r1-r2)+5.15*(g1-g2)+b1-b2>0 ? {r:r1,g:g1,b:b1} : {r:r2,g:g2,b:b2};
          dst[px]   = f1*rgb.r + f2*r1 + f3*r2;
          dst[px+1] = f1*rgb.g + f2*g1 + f3*g2;
          dst[px+2] = f1*rgb.b + f2*b1 + f3*b2;
        break;

        case 'darkercolor':
          var rgb = 2.623*(r1-r2)+5.15*(g1-g2)+b1-b2<0 ? {r:r1,g:g1,b:b1} : {r:r2,g:g2,b:b2};
          dst[px]   = f1*rgb.r + f2*r1 + f3*r2;
          dst[px+1] = f1*rgb.g + f2*g1 + f3*g2;
          dst[px+2] = f1*rgb.b + f2*b1 + f3*b2;
        break;

        default: // ******* UNSUPPORTED mode, produces yellow/magenta checkerboard
          var col = (px/4) % this.canvas.width,
              row = Math.floor((px/4) / this.canvas.width),
              odd = (col%8<4 && row%8<4) || (col%8>3 && row%8>3);
          dst[px] = dst[px+3] = 255;
          dst[px+1] = odd ? 255 : 0;
          dst[px+2] = odd ? 0 : 255;
      }
    }
    destContext.putImageData(dstD,offsets.destX,offsets.destY);
}

})();


text:
Q: How to deal with the radius when applying Euler's formula to determine the roots of a number? I am trying to find $1^{1/3}$. I use Euler's formula $1^{1/3} = (re^{i\theta + 2\pi*k})^{1/3}$
Why are you able to directly this time calculate r? Is r implicitly defined as magnitude?

A: To find $1^{1/3}$, you want $z\in\mathbb{C}$ such that
$$
z^3=1.
$$
Now writing $z=re^{i\theta}$, one has
$$
r^3e^{i3\theta}=1
$$
Taking the absolute value on both sides, and noting that $r>0$, you get $r=1$. For $\theta$, note that $$1=e^{2\pi i}$$ which implies that
$$
3\theta+2k\pi=2\pi,\quad k\in\mathbb{Z}.
$$

A: in this formula, $r$and $\theta$ are both real numbers, and $r$ is nonnegative.
So you get
$$
r^{1/3} \left[ \cos \frac{\theta}{3} + i \sin \frac{\theta}{3} \right].
$$
Post comment additions
Let me add a little detail. The first problem is that $a^b$ has two different meanings.

*

*We define $a^b$, for $a$ real and positive, using logarithms (it's $\exp{b \ln a}$), which are in turn defined by integrals, and $\exp$, which is defined as the inverse function of the natural log.

*We define $z^b$, for $z$ complex and $b$ real, by a somewhat different rule.
The challenge is that when you now write $z^b$ and $z$ happens to be a complex number whose imaginary part is zero...you don't know which rule to use. To keep it clear, I'm going to use $pow(a, b)$ to refer to the thing described in item 1 above. Then we can describe #2 as follows:
Write $z = r (\cos t + i \sin t)$, where $r \ge 0$ is real, and so is $t$. Then
$$
z^b = pow(r, b) (\cos s + i \sin s)
$$
where $s = (t + 2k\pi)b$ for any integer $k$.
This is a little odd, in the sense that there are many possible values for $s$, hence many possible powers of $z$. But what the heck: we have two square roots for nonnegative real numbers already, and just happen to be lucky that there's an easy way to consistently choose one of them (the nonnegative one) to call $\sqrt{x}$.
In the case where $z = 1$ and $b = \frac{1}{3}$, we end up with
$$
1^{1/3} = pow(1, 1/3) (\cos s + i \sin s).
$$
Now $pow(1, 1/3) = 1$, so this simplifies to just
$$
1^{1/3} = \cos s + i \sin s.
$$
where $s = t/3 + 2\pi k/3$, where $t$ is the "angle" for $z = 1$. That angle happens to be $0$, so $s$ is just "any multiple of $2\pi/3$.


text:
Q: phpmyadmin not found issue hey, i installed phpmyadmin and I go to myip/phpmyadmin/ and sign in, but then it's telling me
The requested URL /phpmyadmin/index.php was not found on this server.
I'm running debian and any suggestions on getting it working would be greatly appreciated.
Thanks

A: Try reconfigure to use Apache 2:
$ sudo dpkg-reconfigure phpmyadmin

Try purge phpmyadmin:
$ sudo apt-get purge phpmyadmin
$ sudo rm -rf /etc/phpmyadmin
$ sudo apt-get install phpmyadmin

Also(manual configure Apache2):
$ sudo ln -fvs /etc/phpmyadmin/apache.conf /etc/apache2/conf.d/phpmyadmin.conf
$ sudo service apache2 restart

A: Add this line:
Include /etc/phpmyadmin/apache.conf

To:
/etc/apache2/apache2.conf

A: This solved my problem:
ln -s /etc/apache2/conf.d/phpmyadmin.conf /etc/apache2/conf-enabled/phpmyadmin.conf

A: Try also to use login phpmyadmin instead of root
It works for me


text:
Q: Full-width div on mobile I have this blue top link here and this top is taking all width size, and that's what I want. So if you resize your window or open it on mobile this blue div is putting margins both sides, twitter bootstrap responsive is doing that. My code is exactly like this answer but tb still putting margins, that's my code:

A: I would use a similar media query to target the top background div as its Bootstrap that seems to be adding the body padding. Give this a go:
@media (max-width: 767px) {
  .background-top {
    margin-left: -20px;
    margin-right: -20px;
  }
}


text:
Q: Put all rows from one table to another how I can put all the rows from table A to table B witch all table have the same columns names
ex :
table A :
 x    y   z
 1    2   3
 4    5   6
 7    8   9

table B:
x   y   z
10  11  12

table C should be like this :

x    y   z
1    2   3
4    5   6
7    8   9
10   11  12

PS : I am using a query , I do'nt want to insert in a real table

A: If you only want to select data from A and B, the UNION works:
SELECT x, y, z FROM A
  UNION SELECT x, y, z FROM B

If you want to insert data from A to B (which contradicts your P.S. but corresponds to your first sentence) then this is your solution:
INSERT into B SELECT * from A


text:
Q: Beautifulsoup: Retrieve specific value in table I would like to retrieve the value next to 'Annual Report Expense Ratio (net):' on this webpage:
http://finance.yahoo.com/q/pr?s=NCHAX+Profile
I am using the libaries beautifulSoup and requests.  My code so far is:
from bs4 import BeautifulSoup
import requests
expenseRatioURL = 'http://finance.yahoo.com/q/pr?s=NCHAX+Profile'
rawHTML = requests.get(expenseRatioURL)
soup = BeautifulSoup(rawHTML.content)
g_data = soup.findAll("table", {"class": "yfnc_datamodoutline1"})

g_data is a single element array containing all four tables.
type(g_data)

returns:
<class 'bs4.element.ResultSet'>

How can I retrieve the percentage next to 'Annual Report Expense Ratio (net):'?

A: p = soup.find(text="Annual Report Expense Ratio (net):").parent.next_sibling.string


text:
Q: upgrading xamarin breaks mvvmcross Just upgraded to the latest of Xamarin and now when I build my MvvmCross android app I get the following error:
(0,0): Error: No resource identifier found for attribute 'MvxBind' in package 'com.xxx' (yyy)
I am getting this error for every file where I am using the MvvmCross attributes: MvxBind and MvxItemTemplate
My MvvmCrossAttr.xml file looks like this:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!--<declare-styleable name="CustomFonts">
    <attr name="customFont" format="string" />
  </declare-styleable>-->
  <declare-styleable name="MvxBinding">
    **<attr name="MvxBind" format="string"/>**
    <attr name="MvxLang" format="string"/>
  </declare-styleable>
  <declare-styleable name="MvxListView">
    <attr name="MvxItemTemplate" format="string"/>
    <attr name="MvxDropDownItemTemplate" format="string"/>
    <attr name="GroupItemTemplate" format="string"/>
  </declare-styleable>
  <item type="id" name="MvxBindingTagUnique"/>
  <item type="id" name="MvxBindableListItemTagUnique"/>
  <declare-styleable name="MvxImageView">
    <attr name="MvxSource" format="string"/>
  </declare-styleable>
</resources>

And this is how I am using it in a layout file:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:local="http://schemas.android.com/apk/res/com.xxx"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/shape_search_property_button_border"
    android:clickable="true"
    local:MvxBind="Click NavigateToRestaurantCommand"
    android:padding="1dp">
...

This is very frustrating. Any thoughts?


text:
Q: Ecipse.ini file dash(-) usage I am trying to understand the eclipse.ini file though I understand the purpose of the tags and their values. However I am concerned about the usage of dash being used in every line differently.
Hence this query:
--launcher.XXMaxPermSize (2 dash at the beginning of line)

256M

-showsplash (Only 1 dash at the beginning of the line)

org.eclipse.platform

Is any line a commented line?

A: Neither of these are comments, it is just that some options start with a single dash and others with two dashes (generally the --launcher.xxx options).
The available options are listed here


text:
Q: $\lim_{z\to 0}f(z)=0$ along $y=mx^n$ but for which $\lim_{z\to 0}f(z)$ does not exist Given a nonzero real number $m$, construct a function $f(z)$ such that
$$
\lim_{z\to 0}f(z) = 0
$$
along each curve of the form $y = m\cdot x^n$ (for $n = 1,2,3,4,\dots$), but for which
$$\lim_{z\to 0}f(z)$$
does not exist. I don't know from where I should start.
Thank you ...

A: $f(z) = 0$ on the union of the curves $y =mx^n$, $f(z) = 1$ in the complementary.
The union of curves $y = mx^n$ with $n\in\Bbb N$ is a "small" set. In particular, the complementary intersects every neighborhood of 0.
If also $m$ is variable you can take
$f(x,y) = 0$ when $|y|\ge e^{-1/x^2}$ or $y=0$ and 1 in the complementary.


text:
Q: Javascript change the value of a key I have some data that looks like this:
obj = {
    pref: {
      language: 'English',
    }
};

I want to change the value of language to 'Spanish'

A: You can simply use obj.pref.language = 'Spanish' or obj['pref']['language'] = 'Spanish'.

A: Use dot notation to access the key and change the value

let obj = {
  pref: {
    language: 'English',
  }
};

obj.pref.language = 'Spanish';

console.log(obj)


text:
Q: Button inside widget android I have a widget and I want to put a button inside of it. How would I do this?
-Thanks

A: Did you try reading the Dev Guide?
http://developer.android.com/guide/topics/appwidgets/index.html
Check also Lars Vogel's tutorial here:
http://www.vogella.de/articles/AndroidWidgets/article.html


text:
Q: Align text on \t, colon and \t I have the following raw text that I wrap in a
 tag to salvage as much of the layout as possible:

test

field 1 :   Foo
longer field 2  :   Bar
very long field 3   :   FooBar

other text and values

The field and values are separated by a tab char (\t) a colon and a tab char(\t).
I would like to align the colons so the rendered result would be:
test

field 1             :       Foo
longer field 2      :       Bar
very long field 3   :       FooBar

other text and values

You'll find a jsfiddle here with my effort so far.
I don't have much control over the text but I tried to replace the \t:\t with a  so I get some control with css styling but so far not much joy.
This is the javascript I use to replace the \t:\t with a span:
$('pre').html(
        $('pre')
        .html()
        .split('\t:\t')
        .join(' : '));

and added this css rule to float the  but that
.tab {
    background-color:red;
    width: 10em;
    display: inline-block;
    text-align: right;
    float: left;
}

renders the span at the start of each new line. I've tried also position: absolute to no avail.
What are my options to get the colons aligned?

A: Using CSS as the primary driver:

$(document).ready(function() {
    $('pre').html(
        $('pre')
        .html()
        .replace(/(.*)\t:\t(.*)/g,function(_,key,value) {
            return '
'+
                ''+key+''+
                ' : '+
                ''+value+''+
            '
';
        })
    );
});
pre {display:table}
.row {display:table-row}
.col {display:table-cell}

    test

    field 1 : Foo
    longer field 2 : Bar
    very long field 3  : FooBar

    other text and values

The important thing here is that the JavaScript will scan for lines of the required format (key[tab]:[tab]value) and dress them up in suitable elements. The CSS then makes them uniform.

A: Okay, so this was actually a pretty fun one to suss out.
Example fiddle with dynamic width
Here's what we're doing:
JavaScript
$(document).ready(function() {
    var arr = $('pre').html().split('\n');
    for (var i=0,l=arr.length;i<l;i++){
        if (arr[i].indexOf(':') > -1) {
            var pieces = arr[i].split(':');
            arr[i] = "" + pieces[0] + ": " + pieces[1];
        }
    }

    $('pre').html(arr.join("\n"));
    var maxWidth = Math.max.apply(null, $('.left').map(function () {
        return $(this).outerWidth(true);
    }).get());
    $('.left').css('width', maxWidth + 15);
});

CSS
.left {
    display: inline-block;
}

Explanation of JavaScript
We're separating your pre based on the line instead of the colon, here:
var arr = $('pre').html().split('\n');

Then we're iterating over that looking for a : to separate:
if (arr[i].indexOf(':') > -1)

If we find one, we know that we need to do our super-fancy custom alignment.  We do that by splitting on the : and then wrapping the left side in a span, like so:
var pieces = arr[i].split(':');
arr[i] = "" + pieces[0] + ": " + pieces[1];

Then, we add the modified HTML back to the pre and run this fancy little calculation to find the widest piece:
var maxWidth = Math.max.apply(null, $('.left').map(function () {
  return $(this).outerWidth(true);
}).get());

Stolen shamelessly from this answer
Then apply the widest width to each left element plus an additional 15px of padding at the end.
$('.left').css('width', maxWidth + 15);

Hope that helps!


text:
Q: PhotoSwipe videos I want to add videos to my PhotoSwipe gallery.
I read the documentation here:
http://photoswipe.com/documentation/custom-html-in-slides.html
Unfortunately, I don't get what this means:
"If you really need to have video in PhotoSwipe, you may add it as modal
that appears when user taps on current slide, you can dynamically create
modal in DOM and append it after .pswp__scroll-wrap element."
Has anyone been successful in making videos working reliably with PhotoSwipe?
Edit: I've tried this (last slide is a video): http://pixelkrams.de/2015/artspin Works on desktop but breaks on mobile (video does not start and its size is wrong).
Relevant code: http://pixelkrams.de/js/main.js
Snippet from the PhotoSwipe initialization:
    // Pass data to PhotoSwipe and initialize it
    gallery = new PhotoSwipe( pswpElement, PhotoSwipeUI_Default, dataLarge, options);
    gallery.init();
    gallery.listen('afterChange', function() {
        detectVideo(gallery);
    });

    gallery.listen('beforeChange', function() {
       removeVideo();
    });
   gallery.listen('resize', function() {
       if ($('.videoHolder').length > 0) updateVideoPosition(gallery);
   });
   gallery.listen('close', function() {
       removeVideo();
   });

   detectVideo(gallery);

and the relevant functions for video:
function removeVideo() {
    if ($('.videoHolder').length > 0) {
        if ($('#video').length > 0) {
            $('video')[0].pause();
            $('video')[0].src = "";
            $('.videoHolder').remove();
            $('.pswp__img').css('visibility','visible');
        } else {
            $('.videoHolder').remove();
        }
    }
}

function detectVideo(gallery) {
    var src = gallery.currItem.src;
    if (src.indexOf('video')>= 0) {
        addVideo(gallery.currItem);
        updateVideoPosition(gallery);
    }
}
function addVideo(item, vp) {
    var videofile = item.src.split(".");
    var v = $('
', {
                class:'videoHolder',
                css : ({'position': 'absolute','width':item.w, 'height':item.h})

    });
    v.one('click touchstart', (function() {
        var playerCode = '<video id="video" width="'+item.w+'" height="'+item.h+'" autoplay controls>' +
        '<source src="'+videofile[0]+'.mp4" type="video/mp4"></source>' +
        '<source src="'+videofile[0]+'.webm" type="video/webm"></source>' +
        '</video>';
         $(this).html(playerCode);
         $('.pswp__img').css('visibility','hidden');

    }));
    v.appendTo('.pswp__scroll-wrap');
}

function updateVideoPosition(o) {
    var item = o.currItem;
    var vp = o.viewportSize;
    var top = (vp.y - item.h)/2;
    var left = (vp.x - item.w)/2;
    $('.videoHolder').css({position:'absolute',top:top, left:left});

}

A: For the mobile size issue, I used an additional function that calculates the video size based on gallery.viewportSize and the videos aspect ratio.
function setVideoSize(item, vp) {
    var w = item.w,
        h = item.h,
        vw = vp.x,
        r,
        vh;
    if (vw < w) {
        r = w/h;
        vh = vw/r;
        w = vw;
        h = vh;
    }
    return {
            w: w,
            h: h
    };
}

Then change the addVideo call in detectVideo() to
addVideo(gallery.currItem, gallery.viewportSize);

Use it in the existing addVideo(item, vp) function
var vsize = setVideoSize(item, vp);
var v = $('
', {
            class:'.videoHolder',
            css : ({'position': 'absolute','width':vsize.w, 'height':vsize.h})

And also in updateVideoPosition(o)
var item = o.currItem;
var vp = o.viewportSize;
var vsize = setVideoSize(item, vp);
var top = (vp.y - vsize.h)/2;
var left = (vp.x - vsize.w)/2;
$('.videoHolder').css({position:'absolute',top:top, left:left});

A: Here is my solution to use Photoswipe with Youtube&Vimeo videos.
It is a mix of java-script libraries and solutions which I saw here at Stackoverflow and on the web.
Stylings
<link href="photoswipe.css" rel="stylesheet">
<link href="default-skin/default-skin.css" rel="stylesheet">

Markup (the standard one)

                <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>
                <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>
                <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>

            <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
            </button>
            <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
            </button>

Items

Scripts

YouTubePopUp.jquery.js (this is a jQuery Plugin by Qassim Hassan). You need to download it as well. I've made some custom changes in it, so after downloading simply replace the js-code with mine.
/*
    Name: YouTubePopUp
    Description: jQuery plugin to display YouTube or Vimeo video in PopUp, responsive and retina, easy to use.
    Version: 1.0.1
    Plugin URL: http://wp-time.com/youtube-popup-jquery-plugin/
    Written By: Qassim Hassan
    Twitter: @QQQHZ
    Websites: wp-time.com | qass.im | wp-plugins.in
    Dual licensed under the MIT and GPL licenses:
        http://www.opensource.org/licenses/mit-license.php
        http://www.gnu.org/licenses/gpl.html
    Copyright (c) 2016 - Qassim Hassan

    Mod by MaximusBaton
*/

(function ( $ ) {

    $.fn.YouTubePopUp = function(options) {

        var YouTubePopUpOptions = $.extend({
                autoplay       : 1,
                controls       : 1,
                cc_load_policy : 0,
                iv_load_policy : 3,
                rel            : 0,
                showinfo       : 0
        }, options );

        $(this).on('click', function (e) {

            var youtubeLink = $(this).attr("href");

            if( youtubeLink.match(/(youtube.com)/) ){
                var split_c = "v=";
                var split_n = 1;
            }

            if( youtubeLink.match(/(youtu.be)/) || youtubeLink.match(/(vimeo.com\/)+[0-9]/) ){
                var split_c = "/";
                var split_n = 3;
            }

            if( youtubeLink.match(/(vimeo.com\/)+[a-zA-Z]/) ){
                var split_c = "/";
                var split_n = 5;
            }

            var getYouTubeVideoID = youtubeLink.split(split_c)[split_n];

            var cleanVideoID = getYouTubeVideoID.replace(/(&)+(.*)/, "");

            if( youtubeLink.match(/(youtu.be)/) || youtubeLink.match(/(youtube.com)/) ){
                var videoEmbedLink = "https://www.youtube.com/embed/"+cleanVideoID+"?autoplay="+YouTubePopUpOptions.autoplay+"&controls="+ YouTubePopUpOptions.controls +"&cc_load_policy="+ YouTubePopUpOptions.cc_load_policy +"&iv_load_policy="+ YouTubePopUpOptions.iv_load_policy +"&rel="+ YouTubePopUpOptions.rel +"&showinfo="+ YouTubePopUpOptions.showinfo +"";
            }

            if( youtubeLink.match(/(vimeo.com\/)+[0-9]/) || youtubeLink.match(/(vimeo.com\/)+[a-zA-Z]/) ){
                var videoEmbedLink = "https://player.vimeo.com/video/"+cleanVideoID+"?autoplay="+YouTubePopUpOptions.autoplay+"";
            }

            $("body").append('

Loading...

');
            $('.YouTubePopUp-Content iframe')[0].onload = function() {
                $('.YouTubePopUp-Wrap .loading').hide();
                $('.YouTubePopUp-Wrap iframe').show();
            };

            if( $('.YouTubePopUp-Wrap').hasClass('YouTubePopUp-animation') ){
                setTimeout(function() {
                    $('.YouTubePopUp-Wrap').removeClass("YouTubePopUp-animation");
                }, 600);
            }

            $(".YouTubePopUp-Wrap, .YouTubePopUp-Close").click(function(){
                $.event.trigger({type : 'youtubeVideoBeforeClose', link : youtubeLink});
                $(".YouTubePopUp-Wrap").addClass("YouTubePopUp-Hide").delay(515).queue(function() { $(this).remove(); });
            });

            $.event.trigger({type : 'youtubeVideoStarted', link : youtubeLink});

            e.preventDefault();

        });

        $(document).keyup(function(e) {

            if ( e.keyCode == 27 ){
                $('.YouTubePopUp-Wrap, .YouTubePopUp-Close').click();
            }

        });

    };

}( jQuery ));

custom.js (the main js :)
$(document).ready(function () {

    var mediaList              = [];

    var interval,
        intervalTries = 0,
        maxIntervalTries = 40;

    mediaList.push({
        'src'   : 'file58dc530580a94.jpg',
        'w'     : 1726,
        'h'     : 2506
    });

    mediaList.push({
        'src'   : 'file58dae7f57ea15.jpg',
        'w'     : 4032,
        'h'     : 3024
    });

    mediaList.push({
        'src'   : 'file58daa7b097cc2.jpg',
        'w'     : 3799,
        'h'     : 2849
    });

    mediaList.push({
        'src'      : 'file58dc530580a94.jpg',
        'w'        : 1000,
        'h'        : 667,
        'videoSrc' : '//www.youtube.com/watch?v=a_Ypr_uV-mw'
    });

    var pswpElement = $('.pswp.pswp-chat')[0];
    $(document).on("click", ".media", function(e){
        e.preventDefault();
        var index   = $(this).data("index"),
            options = {
                index           : index,
                bgOpacity       : 0.7,
                overlayIcon     : true,
                showHideOpacity : true
            },
            gallery = new PhotoSwipe( pswpElement, PhotoSwipeUI_Default, mediaList, options);

        gallery.init();

        gallery.listen('close', function() {
            removeVideo(gallery);
        });

        gallery.listen('beforeChange', function() {
            removeVideo(gallery);
        });

        gallery.listen('afterChange', function() {
            detectVideo(gallery.currItem);
        });

        gallery.listen('resize', function() {
            resizeItem(gallery.currItem);
        });

        gallery.listen('imageLoadComplete', function(index, item) {
            resizeItem(gallery.currItem);
        });

        detectVideo(gallery.currItem);

        $(document).off('pswpTap').on('pswpTap', function(e){
            var container = $(gallery.currItem.container),
                img       = container.find('img.youtubeClass');

            if (img.length) {
                if (typeof(img.data('youtubeVideoStarted')) == 'undefined') {
                    img.data('youtubeVideoStarted', false);
                }

                if (img.data('youtubeVideoStarted') === false) {
                    img.data('youtubeVideoStarted', true);

                    if (typeof(img.data('youtubeInitialed')) == 'undefined') {
                        img.data('youtubeInitialed', false);
                    }

                    if (img.data('youtubeInitialed') === false) {
                        img.data('youtubeInitialed', true);
                        img.YouTubePopUp();
                    }

                    if (e.detail.pointerType != 'mouse') {
                        img.click();
                    }
                }
            }
        });

        $(document).off('youtubeVideoStarted').on('youtubeVideoStarted', function(e){
            var container = $(gallery.container),
                img       = container.find('img.youtubeClass[href="'+ e.link +'"]');

            if (img.length) {
                container = img.closest('.pswp__item');

                if (container.length) {
                    var buttonContainer = container.find('.gallery-viewer-play-video-btn-container');

                    img.fadeOut(200);

                    if (buttonContainer.length) {
                        buttonContainer.fadeOut(200);
                    }
                }

            }
        });

        $(document).off('youtubeVideoBeforeClose').on('youtubeVideoBeforeClose', function(e){
            var container = $(gallery.container),
                img       = container.find('img.youtubeClass[href="'+ e.link +'"]');

            if (img.length) {
                container = img.closest('.pswp__item');

                if (container.length) {
                    var buttonContainer = container.find('.gallery-viewer-play-video-btn-container');

                    img.fadeIn(300);
                    img.data('youtubeVideoStarted', false);

                    if (buttonContainer.length) {
                        buttonContainer.fadeIn(300);
                    }
                }

            }
        });
    });

    function resizeItem(item) {
        var container = $(item.container),
            children  = container.children();

        if (children.length > 1) {
            var newWidth  = $(children[ children.length - 1 ]).css('width'),
                newHeight = $(children[ children.length - 1 ]).css('height');

            children.css({
                'width'  : newWidth,
                'height' : newHeight
            });
        }
    }

    function removeVideo(gallery) {
        clearVideoInterval();

        var container        = $(gallery.container),
            buttonContainers = container.find('.gallery-viewer-play-video-btn-container');

        $.each(buttonContainers, function(){
            var $thisButtonContainer = $(this),
                container            = $thisButtonContainer.closest('.pswp__item');

            if (container.length) {
                var img = container.find('img:not(.youtubeClass)');

                $thisButtonContainer.remove();

                if (img.length) {
                    img.show();
                }
            }
        });
    }

    function detectVideo(item) {
        clearVideoInterval();

        if (typeof(item.videoSrc) != 'undefined') {
            interval = setInterval(function(){ addVideoIframe(item); }, 100);
        }
    }

    function clearVideoInterval() {
        clearInterval(interval);
        intervalTries = 0;
    }

    function addVideoIframe(item) {
        if (intervalTries >= maxIntervalTries) {
            clearVideoInterval();
            return;
        }

        intervalTries++;

        var container = $(item.container),
            img       = container.find('img:not(.youtubeClass)');

        if (img.length) {
            resizeItem(item);

            var imgSrcCode      = '_'+ img.attr('src'),
                buttonContainer = container.find('.gallery-viewer-play-video-btn-container');

            if (buttonContainer.length == 0) {
                buttonContainer = $('
<button><svg height="100%" version="1.1" viewBox="0 0 68 48" width="100%"><path class="ytp-large-play-button-bg" d="m .66,37.62 c 0,0 .66,4.70 2.70,6.77 2.58,2.71 5.98,2.63 7.49,2.91 5.43,.52 23.10,.68 23.12,.68 .00,-1.3e-5 14.29,-0.02 23.81,-0.71 1.32,-0.15 4.22,-0.17 6.81,-2.89 2.03,-2.07 2.70,-6.77 2.70,-6.77 0,0 .67,-5.52 .67,-11.04 l 0,-5.17 c 0,-5.52 -0.67,-11.04 -0.67,-11.04 0,0 -0.66,-4.70 -2.70,-6.77 C 62.03,.86 59.13,.84 57.80,.69 48.28,0 34.00,0 34.00,0 33.97,0 19.69,0 10.18,.69 8.85,.84 5.95,.86 3.36,3.58 1.32,5.65 .66,10.35 .66,10.35 c 0,0 -0.55,4.50 -0.66,9.45 l 0,8.36 c .10,4.94 .66,9.45 .66,9.45 z" fill="#1f1f1e" fill-opacity="0.81"></path><path d="m 26.96,13.67 18.37,9.62 -18.37,9.55 -0.00,-19.17 z" fill="#fff"></path><path d="M 45.02,23.46 45.32,23.28 26.96,13.67 43.32,24.34 45.02,23.46 z" fill="#ccc"></path></svg></button>
');

                var clonedImg = img.clone();
                clonedImg.attr('href', item.videoSrc)
                    .addClass('youtubeClass')
                    .removeClass('pswp__img')
                    .css({
                        'width'  : '100%',
                        'height' : '100%'
                    });

                buttonContainer.prepend( clonedImg );
            }

            buttonContainer.css({
                    'width'  : img.outerWidth() +'px',
                    'height' : img.outerHeight() +'px'
                })
                .appendTo(container);

            img.hide();

            clearVideoInterval();
        }
    }
});

Have fun!

A: Via the jAlbum PhotoSwipe skin, see http://jalbum.net/nl/skins/skin/PhotoSwipe, it is possible to add a video to the PhotoSwipe gallery. To see it open the Sample album: http://andrewolff.jalbum.net/Reestdal_PS/
I use the next code for the first 2 images and the next video in the skin code:
  // build items array
var items = [
  {
   src: 'slides/151228-112819_Kerststal.jpg',
   w: 1625,
   h: 1080,
   title: 'Vooraan: Maria\'s dorp.'
 },
  {
   src: 'slides/20150703-ch_IMG_2160.jpg',
   w: 810,
   h: 1080,
   title: 'My Cabin!
Hey boss, I must\'ve taken a wrong turn, cause I\'m stuck up here!'
  },
  {
   html: '<video controls autoplay  style="padding-top: 40px;"><source src="slides/IMG_4979.mp4" type="video/mp4"></video>'
  },


text:
Q: Complex Numbers Question, IIT JEE [2006]. Please tell me whether I solved it properly? $Q.$The value of $\sum\limits_{k=1}^{10}(\sin{\frac{2k\pi}{11}-i\cos\frac{2k\pi}{11}})$ is-?
I solved it like this-
$\frac{\sum\limits_{k=1}^{10}(\cos{\frac{2k\pi}{11}+i\sin\frac{2k\pi}{11}})}{i}$

If we observe these are the roots of the equation $z^{11}=1$
So $1+z_1+z_2+...+z_{10}=1$ (De Moivre
s Theorem)
So $z_1+z_2+...+z_{10}=-1$
$-1=i^2$
 So $\frac{i^2}{i}=i$

A: If you insert an extra term corresponding to $k=0$, which is $-i$, that will be the negative of the sum of all the $11$th roots of unity, i.e. the coefficient of $x^{10}$ in $x^{11}-1$. This sum is zero hence the answer for your question is $+i$, after pulling out the inserted extra term. This is essentially what you have done, and you are correct.

A: Let $$\zeta_{11} = e^{2\pi i/11} = \cos \frac{2\pi}{11} + i \sin \frac{2\pi}{11}$$ be a primitive $11^{\rm th}$ root of unity; hence $$\zeta_{11}^0, \zeta_{11}^1, \ldots, \zeta_{11}^{10}$$ are the roots of $z^{11} - 1 = 0$, and the sum of these roots is therefore zero.  Then
$$\begin{align*} \sum_{k=1}^{10} \left( \sin \frac{2\pi k}{11} - i \cos \frac{2\pi k}{11} \right) &= \frac{1}{i} \sum_{k=1}^{10} e^{2\pi i k/11} \\ &= \frac{1}{i}\left( -1 + \sum_{k=0}^{10} \zeta_{11}^k \right) \\ &= \frac{1}{i} (-1) \\ &= i. \end{align*}$$

To see that the sum of the aforementioned roots is zero, we could also have explicitly summed the geometric series:  $$\sum_{k=0}^{n-1} \zeta_n^k = \frac{\zeta_n^n - 1}{\zeta_n - 1} = \frac{0}{\zeta_n - 1} = 0,$$ for $n > 2$.

A: $$\frac1i\sum_{k=1}^{10}\left(\cos\frac{2k\pi}{11}+i\sin\frac{2k\pi}{11}\right)=-i\sum_{k=1}^{10} \left(e^{\frac{2\pi i}{11}}\right)^k=$$
$$=-ie^{\frac{2\pi i}{11}}\frac{e^{\frac{2\cdot10\pi i}{11}}-1}{e^{\frac{2\pi i}{11}}-1}=-ie^{\frac{2\pi i}{11}}\frac{e^{\frac{-2\pi i}{11}}-1}{e^{\frac{2\pi i}{11}}-1}=-i\frac{e^{\frac{2\pi i}{11}}-1}{1-e^{\frac{2\pi i}{11}}}=i$$

A: $\bf{My\; Solution::}$ Given $$\displaystyle \sin \left(\frac{2k\pi}{11}\right)-i \cos \left(\frac {2k\pi}{11}\right) = -i\cdot \left[\cos \left(\frac {2k\pi}{11}\right)+i\cdot \sin \left(\frac {2k\pi}{11}\right)\right]$$
Now We know that $$e^{i\phi} = \cos \phi+i\sin \phi$$ and $$e^{-i\phi}=\cos \phi+i\sin \phi$$
So We Write $$\displaystyle \sin \left(\frac{2k\pi}{11}\right)-i \cos \left(\frac {2k\pi}{11}\right)=-i\cdot e^{i\frac{2k\pi}{11}} = -i\cdot e^{ik\phi}\;,$$ Where $$\displaystyle \phi = \frac{2\pi}{11}$$
So We have  $$\displaystyle \sum_{k=1}^{10}\displaystyle \sin \left(\frac{2k\pi}{11}\right)-i \cos \left(\frac {2k\pi}{11}\right) = -i\sum_{k=1}^{10}e^{ik\phi} = -i\left[e^{i\phi}+e^{2i\phi}+........+e^{10i\phi}\right]$$
Above is Sum of $\bf{10-}$  terms of $\bf{G.P}.$
So We get $$\displaystyle = -i\cdot \left[\frac{e^{i\phi}-e^{11i\phi}}{1-e^{i\phi}}\right] = -i\cdot \left[\frac{e^{i\phi}-1}{1-e^{i\phi}}\right]=+i$$
Bcz $$\displaystyle e^{11i\phi} = \cos 11\phi+i\sin 11 \phi = \cos \left(11\cdot \frac{2\pi}{11}\right)+i\sin \left(11\cdot \frac{2\pi}{11}\right)=1\;,$$ Bcz $$\displaystyle \phi = \frac{2\pi}{11}$$

A: $\begin{array}{l}
\\
\sum \limits^{10}_{k=1}(\sin \ \frac{2k\pi }{11} -i\cos \frac{2k\pi }{11}  )\\
=(-i)\sum \limits^{10}_{k=1}(\cos  \frac{2k\pi }{11} +i\sin \frac{2k\pi }{11}  )\\
=(-i)(\sum \limits^{10}_{k=0}(\cos  \frac{2k\pi }{11} +i\sin \frac{2k\pi }{11} )-1)\\
=(-i)(-1)\\
=i\\
Note:
\sum \limits^{10}_{k=0}(\cos \frac{2k\pi }{11} +i\sin \frac{2k\pi }{11}  )=0\\
\end{array}$
Sum of $11^{th}$ roots of unity =$0$


text:
Q: Запрос на изменение даты. Время должно оставаться без изменений Столкнулся с такой проблемой.
Необходимо изменить дату заявок, но при этом оставить время как и было изначально указано.
Видел похожую тему, но тот вариант решение проблемы, вечно mssql выдает ошибку.
Так заменяю дату, но меняется и время на 00:00:00.000
update Application SET
registrationDate = '2022-06-11'
WHERE registrationdate  BETWEEN '2022-06-11 00:00:00.000' and '2022-06-11 23:59:59.000'

A: update Application SET
registrationDate = '2022-06-11' + ' ' + convert(varchar(20),registrationDate, 14)
WHERE registrationdate  BETWEEN '2022-06-11 00:00:00.000' and '2022-06-11 23:59:59.000'


text:
Q: Excel VBA Exit For does not work inside If block Dim valCheck As Variant

For i = 0 To row1
    For j = 0 To col1
        MsgBox ("started" & i)
        valCheck = Range("A1").Offset(i, j).Value
        MsgBox (valCheck)
        If valCheck = "Details" Then
            MsgBox ("found")
            ActiveCell = Range("A1").Offset(i + 1, j)
            Exit For
            Exit For
        End If
    Next j
Next i

A: You don't need to have 2 For loops and Exit For, you can simply use the Find function instead.
Dim FindRng As Range

Set FindRng = Cells.Find("Details")
If Not FindRng Is Nothing Then ' Find was successful
    FindRng.Select ' <-- not sure what you want to do after you find the cell with "Details" ?
Else ' Find failed
    MsgBox "Unable to find 'details'", vbCritical
End If

A: As soon as the first Exit For executes, it bypasses the second. You need to place the second Exit For outside the inner loop.
Dim valCheck As Variant

For i = 0 To row1
    For j = 0 To col1
        MsgBox ("started" & i)
        valCheck = Range("A1").Offset(i, j).Value
        MsgBox (valCheck)
        If valCheck = "Details" Then
            MsgBox ("found")
            ActiveCell = Range("A1").Offset(i + 1, j)
            Exit For
        End If
    Next j
    If valCheck = "Details" Then Exit For
Next i


text:
Q: Error in `row.names<-.data.frame`(`*tmp*`, value = c(NA_real_, NA_real_ I am trying to build a model using the tweets and polarity.
But in the middle I get this weird error:
At this line:
analytics <- create_analytics(container, MAXENT_CLASSIFY)

I get this

Error in `row.names<-.data.frame`(`*tmp*`, value = c(NA_real_, NA_real_,  :
  duplicate 'row.names' are not allowed
In addition: Warning messages:
1: In cbind(labels, BEST_LABEL = as.numeric(best_labels), BEST_PROB = best_probs,  :
  NAs introduced by coercion
2: In create_documentSummary(container, score_summary) :
  NAs introduced by coercion
3: In cbind(MANUAL_CODE = testing_codes, CONSENSUS_CODE = scores$BEST_LABEL,  :
  NAs introduced by coercion
4: In create_topicSummary(container, score_summary) :
  NAs introduced by coercion
5: In cbind(TOPIC_CODE = as.numeric(as.vector(topic_codes)), NUM_MANUALLY_CODED = manually_coded,  :
  NAs introduced by coercion
6: In cbind(labels, BEST_LABEL = as.numeric(best_labels), BEST_PROB = best_probs,  :
  NAs introduced by coercion
7: non-unique values when setting 'row.names':

My CSV file looks like:
text, polarity
Hello I forget the password of my credit card need to know how I can make my statement, neutral
can provide the swift code thanks, neutral
thanks just one more doubt has this card commissions with these characteristics, neutral
Thanks, neutral
are arriving mail scam, negative
can you help me I need to pay an online purchase and ask me for a terminal my debit which is, neutral
if I do not win anything this time I change banks, negative
you can be the next winner of the million that circumvents account award date January, neutral
account and see my accounts so I can have the, negative
thanks i just send the greetings consultation, neutral
may someday enable office not sick people, negative
hello is running payments through the online banking no, negative
thanks hope they do, neutral
should pay attention to many happened to us that your system flushed insufficient balance or had no money in the accounts, negative
yesterday someone had the dignity to answer the telephone banking and verify that the system is crap, negative
and tried but apparently the problem is just to pay movistar services, neutral
good morning was trying to pay for services through the website but get error retry in minutes, negative
if no system agent is non clients or customers also, positive

The code I am using is:
library(RTextTools)

pg <- read.csv("cleened_tweets.csv", header=TRUE, row.names=NULL)

head(pg)

pgT <- as.factor(pg$text)

pgP <- as.factor(pg$polarity)

doc_matrix <- create_matrix(pgT, language="spanish", removeNumbers=TRUE, stemWords=TRUE, removeSparseTerms=.998)

dim(doc_matrix)

container <- create_container(doc_matrix, pgP, trainSize=1:275, testSize=276:375, virgin=FALSE)

MAXENT <- train_model(container,"MAXENT")

MAXENT_CLASSIFY <- classify_model(container, MAXENT)

analytics <- create_analytics(container, MAXENT_CLASSIFY)

summary(analytics)

A: I have also encountered this error with RTextTools. The create_analytics function cannot handle factor variables or strings -- only numeric labels. I usually just merge my text labels back on at the end after running this code.

A: Convert your pgP variable from as.factor to as.numeric. This should re-solve the issue
pgP <- as.numeric(as.factor(pg$polarity))


text:
Q: Not able to install javaMail-1.5 feature in liberty via server.xml I can install the javaMail-1.5 feature fine using the following command "installUtility install javaMail-1.5" on my running liberty server and following the prompts.
However according to the liberty documentation I should be able to install it by adding the following to my server.xml config in the featureManager tag:
javaMail-1.5
This doesn't work and I see the following error in the server startup logs:
[11/30/16 1:22:43:342 UTC] 00000021 id=         com.ibm.ws.kernel.feature.internal.FeatureManager            E CWWKF0042E: A feature definition cannot  be found for the  javamail-1.5 feature.  Try running the command, bin/installUtility install javamail-1.5,  to install the feature. Alternatively, you can run the command, bin/installUtility install authentication,  to install all features that are referenced by this configuration.
My server details are as below:
product = WebSphere Application Server 16.0.0.3 (wlp-1.0.14.cl160320160831-1555)
java.version = 1.8.0
java.runtime = Java(TM) SE Runtime Environment (pxa6480sr3fp20-20161019_02 (SR3 FP20))
Does anyone have any idea why this doesn't work?

A: If the feature hasn't been installed, you will need to use installUtility to install it as you mentioned.
The error is an indication that the feature -- think binaries -- is not on the system i.e. hasn't been installed.
Specifying it in your server.xml will configure the runtime to use it.  But, it will not install the feature automatically for you.  The server.xml is a server runtime configuration.
Now, what you can do is to try installUtility install <yourServer> or installUtility install <pathToServerXml>, which will have installUtility inspect your server or server.xml and install any features that aren't already installed on the system.

A: I think you may be confusing the documentation for the featureManager command which has been superseded by the installUtility command.  Adding a feature to the featureManager element of your server.xml doesn't install the feature, it enables it.  In order to enable a feature in server.xml, you must first install it using one of the methods described here.


text:
Q: Controls (Play pause buttons) are not displayed in video. My code is as below.
Html Portion

        <img id="sound_img" src="<?=bloginfo( 'template_url' )?>/images/muted.png">

        <img style="margin-left: 100px; margin-top: 40px" id="loading_vidio" src="<?php bloginfo( 'template_url' )?>/images/video_loading.gif"/>
            <video height="341" width="620" poster="<?php bloginfo( 'template_url' )?>/images/video.png" id="banner_advideo">
            <source type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"' src="<?php bloginfo( 'template_url' )?>/video/<?php echo $videoname?>" />
            </video>

Making froth at a touch of a button couldn't be easier.

Javascript Portion
     var me=new MediaElement('banner_advideo', {
         // shows debug errors on screen
         enablePluginDebug: false,
         // remove or reorder to change plugin priority
         plugins: ['flash'],
         // specify to force MediaElement to use a particular video or audio type

         features: ['playpause','progress','current','duration','tracks','volume','fullscreen'],
         success: function (mediaElement, domObject) {

             // call the play method
             $('#loading_vidio').show();
             $('#div_video').show();
             mediaElement.addEventListener('loadeddata', function(e) {
                $('#loading_vidio').hide();
               }, false);
             mediaElement.play();
             mediaElement.setMuted(true);
         },
         // fires when a problem is detected
         error: function () {
         }
     });

Now I the controls(Play pause buttons) are not showing in my video. I read the 2 similar questions and answers regarding this but i am not getting solution from that.
Can anybody tell me what could be the problem with this?

A: Controls are property of MediaElementPlayer object. so i made its object and so it is showing all the controls in a proper manner now.


text:
Q: How to pass a Parcelable Extra to another activity I'm trying to pass a Parceble Extra to another activity using this example, but when I try get it on my second activity NullPointerExeception shows up, could somebody help me?
My Parcelable class:
public class MetaDados implements Parcelable {

    private int codigoInstituicao;
        // . . .

    public MetaDados(int codigoInstituicao, int ano, String offlineUuid, String sigla, String nameInst,
            String startedDate, String name, String finishedDate, long size) {
        this.codigoInstituicao = codigoInstituicao;
        // . . .

    }

    public int getCodigoInstituicao() {
        return codigoInstituicao;
    }

    public void setCodigoInstituicao(int codigoInstituicao) {
        this.codigoInstituicao = codigoInstituicao;
    }

    //getters and setters . . .

    @Override
    public int describeContents() {
        // TODO Auto-generated method stub
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(codigoInstituicao);
        // . . .

    }

    public static final Parcelable.Creator<MetaDados> CREATOR = new Parcelable.Creator<MetaDados>() {
        public MetaDados createFromParcel(Parcel in) {
            return new MetaDados(in);
        }

        public MetaDados[] newArray(int size) {
            return new MetaDados[size];
        }
    };

    private MetaDados(Parcel in) {
        codigoInstituicao = in.readInt();
        //. . .
    }
}

My AsynkTask how start my other activity:
ArrayList<MetaDados> metaDadosFull = new ArrayList<MetaDados>();
ArrayList<MetaDados> metaDadosPres = new ArrayList<MetaDados>();

Intent it = new Intent(activity, DownloadSelectionActivity.class);
            it.putExtra("metaDadosFull", metaDadosFull);
            it.putExtra("metaDadosPres", metaDadosPres);

            activity.startActivity(it);

And my DownloadSelectionActivity where I try to get it:
ArrayList<MetaDados> fullList = (ArrayList<MetaDados>) getIntent().getParcelableExtra("metaDadosFull");

        for (MetaDados metaDados : fullList) {
            Log.d(Constants.DOWNLOAD_SELECTED_ACTIVITY, metaDados.getName());
        }

        ArrayList<MetaDados> presList = (ArrayList<MetaDados>) getIntent().getParcelableExtra("metaDadosPres");

        for (MetaDados metaDados : presList) {
            Log.d(Constants.DOWNLOAD_SELECTED_ACTIVITY, metaDados.getName());
        }

A: Use Intent.putParcelableArrayListExtra() instead of putExtra(), and getParcelableArrayListExtra() instead of getParcelableExtra(). You can lose the casts as well, that may be where it's blowing up.


text:
Q: itext pdf creating in java: Chinese not working when a service call is made from localhost but works fine when called from main method I am trying to create pdf that contains Chinese characters.
It is working as expected when i call generatePdf()` from the main method. The screen shot is shown. However when i deploy in weblogic server and call from the browser "http://localhost:7001/PdfGeneration/itext/genpdf" it doesn't apply the font. I have attached screen shot.
Following settings:

*

*weblogic version: 12.2.1

*Itextpdf,xmlworker: 5.4.5

*Jersey version: 2.2

*Intellij IDE 2016.1.3

*jdk 1.8

style.css contains just this
body {
    font-family: "arial unicode ms";
}

CODE:
@Path("itext")
    @Api(value = "itext service")
    public class iTextService {

//creating an object in main and calling the method works fine
//this part is commented when calling form server (localhost)
        public iTextService() throws Exception {
            generatePdf();
        }

        public static void main(String args[]) throws Exception {
            iTextService obj = new iTextService();
            return;
        }

     @GET
        @Path("genpdf")
        @Produces("application/pdf")
        public void generatePdf() throws Exception {

            ByteArrayOutputStream out = new ByteArrayOutputStream();
            Document doc = new Document(PageSize.A4, 40, 40, 20, 10);
            PdfWriter writer = PdfWriter.getInstance(doc, new FileOutputStream("testPDF.pdf"));

            doc.open();
            parseHTML(writer, doc);
            doc.close();

        }
    //this method gives the artifact path
    // screen shot of the artifact is shown
    public String getFilePath() {
            URL url = getClass().getClassLoader().getResource("/resource/");
            String path = url.getPath();
            try {
                path = URLDecoder.decode(path, "utf-8");
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
            path = new File(path).getPath();
            return path;
    }

     public void parseHTML(PdfWriter writer, Document document) throws Exception {

            //comment this when calling from main method
            String pathToRes = getFilePath();

            //case 1 : calling from main method
            //byte[] encoded = Files.readAllBytes("style.css"));
            //case 2: calling from browser (localhost)
            byte[] encoded = Files.readAllBytes(Paths.get(pathToRes + "\\style.css"));
            String style = new String(encoded);

            CSSResolver cssResolver = new StyleAttrCSSResolver();
            CssFile cssFile = XMLWorkerHelper.getCSS(new ByteArrayInputStream(style.getBytes()));
            cssResolver.addCss(cssFile);

            // HTML
            XMLWorkerFontProvider fontProvider = new XMLWorkerFontProvider(XMLWorkerFontProvider.DONTLOOKFORFONTS);
            //case 1
            //fontProvider.register("ARIALUNI.ttf");
            //case 2
            fontProvider.register(pathToRes + "\\ARIALUNI.ttf");

            //FontFactory.register(pathToFont + "\\ARIALUNI.ttf");
            //FontFactory.setFontImp(fontProvider); //tried with these two along with exisitng code once

            CssAppliers cssAppliers = new CssAppliersImpl(fontProvider);
            HtmlPipelineContext htmlContext = new HtmlPipelineContext(cssAppliers);
            htmlContext.setTagFactory(Tags.getHtmlTagProcessorFactory());

            // Pipelines
            PdfWriterPipeline pdf = new PdfWriterPipeline(document, writer);
            HtmlPipeline html = new HtmlPipeline(htmlContext, pdf);
            CssResolverPipeline css = new CssResolverPipeline(cssResolver, html);

            // XML Worker
            XMLWorker worker = new XMLWorker(css, true);
            XMLParser parser = new XMLParser(worker);
            parser.parse(new ByteArrayInputStream("
篆書 test
".getBytes()), Charset.forName("UTF-8"));
        }

    }

screenshots

A: I found the issue, I used the parse function provided by itext which requires Inputstream as you can see  below
public void parse(InputStream in, Charset charSet) throws IOException {
        this.charset = charSet;
        InputStreamReader reader = new InputStreamReader(in, charSet);
        this.parse((Reader)reader);
    }
And Initially I was doing this
XMLParser parser = new XMLParser(worker);
parser.parse(new ByteArrayInputStream(buildTemplate().getBytes("UTF-8")), Charset.forName("UTF-8"));
Now I created an Inputstream and then I passed it to the parse and it worked.
InputStream is = new ByteArrayInputStream(buildTemplate().getBytes("UTF-8"));
parser.parse(is, Charset.forName("UTF-8"));
For some reason the first method works in local but not when hosted.


text:
Q: Como verificar se o item está na lista em knockout, porque a função isthere retorna 'false'? A duvia é a seguinte:
Quando clico no botão Add To List este executa a função addToList que por sua vez executa a função  isThere que está a a returnar false e este é exactamente o que não entendo.

function Person(firstName, lastName) {
  this.firstName = firstName;
  this.lastName = lastName;
}

function isThere(list, p) {
  var lista = list;
  var person = p;
  var flag = false;
  var i = 0;
  for (i = 0; i < list.length; i = i + 1) {
    if (lista()[i].firstName == person.firstName) {
       flag = true;
    }

  }
  return flag;

}

function AppViewModel() {
  this.firstName = ko.observable("Bert");
  this.lastName = ko.observable("Bertington");
  this.fullName = ko.computed(function() {
    return this.firstName() + " " + this.lastName();
  }, this);

  this.capitalizeLastName = function() {
    var currentVal = this.lastName();
    this.lastName(currentVal.toUpperCase());
  }
  this.isthere = ko.observable("false");
  this.persons = ko.observableArray([]);
  this.addToList = function() {

    var firstName = this.firstName();
    var lastname = this.lastName();
    var p = new Person(firstName, lastname);
    this.persons.push(p);
    this.isthere(isThere(this.persons, p));

  };

}

ko.applyBindings(new AppViewModel());

this.capitalizeLastName = function() {
  var currentVal = this.lastName();
  this.lastName(currentVal.toUpperCase());
};
.row {
  display: flex;
  flex-direction: row;
}

First name: <input data-bind="value: firstName" />

Last name: <input data-bind="value: lastName" />

    <button data-bind="click: capitalizeLastName">Go caps</button>
    <button data-bind="click: addToList">Add To List</button>

[Apenas porque pode ajudar alguem]
exemplo knockout

A: No for, voce acabou usando list.length, quando deveria ser list().length ou lista().length

function Person(firstName, lastName) {
  this.firstName = firstName;
  this.lastName = lastName;
}

function isThere(list, p) {
  var lista = list;
  var person = p;
  var flag = false;
  var i = 0;
  for (i = 0; i < lista().length; i = i + 1) {
    if (lista()[i].firstName == person.firstName) {
       flag = true;
    }

  }
  return flag;

}

function AppViewModel() {
  this.firstName = ko.observable("Bert");
  this.lastName = ko.observable("Bertington");
  this.fullName = ko.computed(function() {
    return this.firstName() + " " + this.lastName();
  }, this);

  this.capitalizeLastName = function() {
    var currentVal = this.lastName();
    this.lastName(currentVal.toUpperCase());
  }
  this.isthere = ko.observable(false);
  this.persons = ko.observableArray([]);
  this.addToList = function() {

    var firstName = this.firstName();
    var lastname = this.lastName();
    var p = new Person(firstName, lastname);
    this.persons.push(p);
    this.isthere(isThere(this.persons, p));

  };

}

ko.applyBindings(new AppViewModel());

this.capitalizeLastName = function() {
  var currentVal = this.lastName();
  this.lastName(currentVal.toUpperCase());
};
.row {
  display: flex;
  flex-direction: row;
}

First name: <input data-bind="value: firstName" />

Last name: <input data-bind="value: lastName" />

    <button data-bind="click: capitalizeLastName">Go caps</button>
    <button data-bind="click: addToList">Add To List</button>


text:
Q: Two-dimensional table of means in summaryBy in R Let's take this code:
library(doBy)
tab <- summaryBy(x ~ A + B, df)

It computes the mean of x for each combination of A & B.
How can I create a 2D table out of tab with A in rows and B in columns, so that the intersection of a row and column gives the mean of x for a group having given combination of A & B?

A: I would skip the intermediate step and use a function that is designed to deliver what you want, namely tapply. Using agsudy's data:
> x.mean <- with(dat, tapply(x, list(A=A,B=B), mean))
> x.mean
   B
A           2         3         4         5
  1 0.3671088 0.4531040 0.5942483 0.8013453
  2 0.4776386 0.6115361 0.7907584 0.6607741
  3 0.3966482 0.3447879 0.4372367 0.4914243
  4 0.2779789 0.6780573 0.4087858 0.4205421
  5 0.6288597 0.6924584 0.6508705 0.5648296

If you really wanted to use the intermediate step you can also use tapply with either the I or c functions to do the rearrangement:
with(tab, tapply(x.mean, list(A=A,B=B), c))
   B
A           2         3         4         5
  1 0.3671088 0.4531040 0.5942483 0.8013453
  2 0.4776386 0.6115361 0.7907584 0.6607741
  3 0.3966482 0.3447879 0.4372367 0.4914243
  4 0.2779789 0.6780573 0.4087858 0.4205421
  5 0.6288597 0.6924584 0.6508705 0.5648296

> with(tab, tapply(x.mean, list(A,B), I))
          2         3         4         5
1 0.3671088 0.4531040 0.5942483 0.8013453
2 0.4776386 0.6115361 0.7907584 0.6607741
3 0.3966482 0.3447879 0.4372367 0.4914243
4 0.2779789 0.6780573 0.4087858 0.4205421
5 0.6288597 0.6924584 0.6508705 0.5648296

A: If I understand I think you are looking to reshape your data. One option is to use dcast from reshape2 package:
dat.s <- summaryBy(x~B+A, data=dat)
library(reshape2)
dcast(dat.s,A~B)

For example:
## create some data
set.seed(1)
dat <- data.frame(x=runif(100),
                  A=sample(1:5,100,rep=TRUE),
                  B=sample(2:5,100,rep=TRUE))

library(doBy)
dat.s <- summaryBy(x~B+A, data=dat)
dat.s <- round(dat.s,2)   ## for better output
library(reshape2)
dcast(dat.s,A~B)

  A    2    3    4    5
1 1 0.37 0.45 0.59 0.80
2 2 0.48 0.61 0.79 0.66
3 3 0.40 0.34 0.44 0.49
4 4 0.28 0.68 0.41 0.42
5 5 0.63 0.69 0.65 0.56


text:
Q: Okta as SP (inbound SAML ) how to configure redirection URL after successful login In my IDP initiated flow. I have created a saml response and sent to Okta's ACS URL Via post request I also sent relay state in hidden input element to ACS URL.
 <form method="post"
  action="{{url}}">
      <input type="hidden"
       name="SAMLResponse"
       value="{{saml_response}}" />

      <input type="hidden"
       name="RelayState"
       id="RelayState"
       value="{{relay_state}}" />
 </form>
 <script>
  window.onload = function (){document.forms[0].submit(); }
 </script>

I am creating the SAML response and sending it to OKta ACS using the above code. The user is logging in successfully but after that, the user is redirected to https://org.okta.com/what-eve-i-have-passed-in-relaystate but I want to redirect the user to a diff domain other than okta.com.
I tried giving a full-fledged URL in the relay state but it didn't work. Am I missing any configuration in Okta?

A: Are you receiving the SAMLResponse to your AssertionConsumerEndpoint when no RelayState is passed?
Based on the following documentation from Okta

A RelayState is an HTTP parameter that can be included as part of the
SAML request and SAML response. In an SP-initiated sign-in flow, the
SP can set the RelayState parameter in the SAML request with
additional information about the request. A SAML IdP, after receiving
the SAML request, takes the RelayState value and simply attaches it
back as an HTTP parameter in the SAML response after the user has been
authenticated. This way, when the round trip completes, the SP can use
the RelayState information to get additional context about the initial
SAML authentication request.

Okta ideally should not redirect directly to the RelayState after authentication.
You should receive back the RelayState as a request parameter along with SAMLResponse  to SP's AssertionConsumerEndpoint. From there, you can redirect to the url in RelayState.

Just to add, instead of url as the value, you can use some id. On receiving it back, extract the details against this id, and then redirect.


text:
Q: How to install Solr 4.x on Tomcat via Puppet? So far I've been using the following recipe for installing Solr 3.x on Tomcat 6:
package { 'openjdk-6-jdk' :
  ensure => installed,
}
package { 'solr-tomcat' :
  ensure => installed,
}

exec { 'tomcat-port':
  command => "sed -i.bak 's|port=\"8080\"|port=\"8983\"|g' /etc/tomcat6/server.xml",
  path => ["/bin", "/usr/bin"],
}

service { 'tomcat6' :
  ensure => running,
  require => Package['solr-tomcat'],
}

However I'd like to install Solr 4.x on Tomcat 7, but it seems Debian doesn't have appropriate packages for Solr (such as solr-tomcat).
I've so far Tomcat 7 working by:
package { [ 'tomcat7', 'tomcat7-admin' ]: ensure => installed, }
service { 'tomcat7' : ensure => running, }
exec { 'tomcat-port':
  command => "sed -i.bak 's|port=\"8080\"|port=\"8983\"|g' /etc/tomcat7/server.xml",
  path => ["/bin", "/usr/bin"],
}

But how do I install Solr 4.x?

A: You can create your own Debian package and host it in your own repository. Projects like FPM (https://github.com/jordansissel/fpm) help a lot here. Another option is to retrieve the Solr tarball from the project website and manage a series of exec statements to extract it into the webapps directory in your Tomcat install.

A: The simplest way is to define exec, for example:
exec { "solr-download":
  command => "/usr/bin/wget http://archive.apache.org/dist/lucene/solr/4.9.1/solr-4.9.1.tgz && /bin/tar -xf solr-4.9.1.tgz"
  cwd => "/opt",
  creates => "/opt/solr-4.9.1.tgz",
}

For more flexible solution, you've to write a class (solr4-tomcat.pp), for example:
class solr {

  # variables
  $version = '4.10.4'
  $data_dir = "/opt/solr/data"
  $home_dir = "/opt/solr/home"

  $tomcat_version = "tomcat7"
  $tomcat_base = "/var/lib/${tomcat_version}"
  $tomcat_user = $operatingsystem ? {
    /RedHat|CentOS/ => "tomcat",
    /Debian|Ubuntu/ => $tomcat_version,
  }

  # includes
  include solr::files

  class { 'tomcat': install_from_source => false }

  # Ensure Java libraries are installed
  package { "java":
    ensure => present,
    name => $operatingsystem ? {
      'Centos' => $operatingsystemrelease ? {
        '6.0' => "java-1.6.0-openjdk.$hardwaremodel",
         '*' => 'openjdk-7-jre',
      },
      /Debian|Ubuntu/ => 'openjdk-7-jre-headless',
    },
  }

  # Set port 8983 for Tomcat 7 and make sure it's running.
  tomcat::instance {'default': package_name => $tomcat_version} ->
    tomcat::service  {'default':
      service_name => 'tomcat7',
      service_ensure => 'running',
      use_jsvc => false, use_init => true,
# use_jsvc => true, java_home => "/usr/lib/jvm/java-7-openjdk-amd64",
    }->
    tomcat::config::server { $tomcat_version:
      catalina_base => $tomcat_base,
      port          => 8983,
    }

  class solr::files {

    # Ensure solr directories are present.
    file { 'home_dir':
      path => $solr::home_dir,
      ensure => directory,
      recurse => true,
    }
    file { 'data_dir':
      path => $solr::data_dir,
      ensure => directory,
      recurse => true,
      owner => $solr::tomcat_user,
      group => $solr::tomcat_user,
    }

    # Download and extract solr
    exec { "solr-extract":
      path    => ['/usr/bin', '/usr/sbin', '/bin'],
      command => "curl -s http://archive.apache.org/dist/lucene/solr/${solr::version}/solr-${solr::version}.tgz | tar zxf -",
      cwd => "/opt/solr",
      require => [File["data_dir"], File["home_dir"]],
      creates => "/opt/solr/solr-${solr::version}/dist/solr-${solr::version}.war",
    }
    # Logging setup for Tomcat.
    exec { 'solr-install-logging-jars':
      path      => ['/usr/bin', '/usr/sbin', '/bin'],
      cwd       => "/opt/solr",
      command   => "cp -v /opt/solr/solr-${solr::version}/example/lib/ext/*.jar /opt/solr/solr-${solr::version}/dist/solrj-lib/*.jar /opt/solr/solr-${solr::version}/example/resources/log4j.properties ${solr::tomcat_base}/webapps/solr/WEB-INF/lib",
      onlyif    => "test ! -f ${solr::tomcat_base}/webapps/solr/WEB-INF/lib/log4j-1.2.17.jar",
      require   => Exec['solr-extract'],
    }
  }

  tomcat::war { 'solr.war':
    catalina_base => $tomcat_base,
    war_source => "/opt/solr/solr-${solr::version}/dist/solr-${solr::version}.war",
    require => Class["solr::files"],
    notify => Service[$tomcat_version],
  }

}

Checkout the alternative manifests:

*

*solr module at parrot-adapt

*solr-tomcat.pp at vm-prodimages


text:
Q: How to enter rails console on production via capistrano? I want to enter the rails console on production server from my local machine via capistrano.
I found some gists, e.g. https://gist.github.com/813291 and when I enter console via
cap production console

I get the following result
192-168-0-100:foldername username $ cap console RAILS_ENV=production
  * executing `console'
  * executing "cd /var/www/myapp/current && rails console production"
    servers: ["www.example.de"]
    [www.example.de] executing command
    [www.example.de] rvm_path=$HOME/.rvm/ $HOME/.rvm/bin/rvm-shell '1.9.3' -c 'cd /var/www/myapp/current && rails console production'
/var/www/myapp/releases/20120305102218/app/controllers/users_controller.rb:3: warning: already initialized constant VERIFY_PEER
Loading production environment (Rails 3.2.1)
Switch to inspect mode.

and thats it... Now I can enter some text, but nothing happens...
Has anybody an idea how to get that work or another solution for my problem?

A: For Capistrano 3 you can add these lines in your config/deploy:
namespace :rails do
  desc 'Open a rails console `cap [staging] rails:console [server_index default: 0]`'
  task :console do
    server = roles(:app)[ARGV[2].to_i]

    puts "Opening a console on: #{server.hostname}...."

    cmd = "ssh #{server.user}@#{server.hostname} -t 'cd #{fetch(:deploy_to)}/current && RAILS_ENV=#{fetch(:rails_env)} bundle exec rails console'"

    puts cmd

    exec cmd
  end
end

To open the first server in the servers list:
cap [staging] rails:console

To open the second server in the servers list:
cap [staging] rails:console 1

Reference: Opening a Rails console with Capistrano 3
exec is needed to replace the current process, otherwise you will not be able to interact with the rails console.

A: A simple Capistrano 3 solution may be:
namespace :rails do
  desc "Run the console on a remote server."
  task :console do
    on roles(:app) do |h|
      execute_interactively "RAILS_ENV=#{fetch(:rails_env)} bundle exec rails console", h.user
    end
  end

  def execute_interactively(command, user)
    info "Connecting with #{user}@#{host}"
    cmd = "ssh #{user}@#{host} -p 22 -t 'cd #{fetch(:deploy_to)}/current && #{command}'"
    exec cmd
  end
end

Then you can call it say, on staging, with: cap staging rails:console. Have fun!

A: I've added my own tasks for this kind of thing:
namespace :rails do
  desc "Remote console"
  task :console, :roles => :app do
    run_interactively "bundle exec rails console #{rails_env}"
  end

  desc "Remote dbconsole"
  task :dbconsole, :roles => :app do
    run_interactively "bundle exec rails dbconsole #{rails_env}"
  end
end

def run_interactively(command)
  server ||= find_servers_for_task(current_task).first
  exec %Q(ssh #{user}@#{myproductionhost} -t '#{command}')
end

I now say cap rails:console and get a console.

A: For Capistrano > 3.5 and rbenv. Working in 2021
namespace :rails do
  desc "Open the rails console on one of the remote servers"
  task :console do |current_task|
    on roles(:app) do |server|
      server ||= find_servers_for_task(current_task).first
      exec %Q[ssh -l #{server.user||fetch(:user)} #{server.hostname} -p #{server.port || 22} -t 'export PATH="$HOME/.rbenv/bin:$PATH"; eval "$(rbenv init -)"; cd #{release_path}; bin/rails console -e production']
    end
  end
end

A: I have fiddled with that approach as well, but then resorted to avoiding building my own interactive SSH shell client and just went with this snippet I found that simply uses good old SSH. This might not be suitable if you have some weird SSH gateway proxying going on, but for logging into a box and performing some operations, it works like a charm.

A: In my experience, capistrano isn't built to work very well with interactive terminals.
If you have to execute things in multiple terminals, I'd suggest iterm, which has a "send to all windows" function that works very well for me:
http://www.iterm2.com/#/section/home

A: I have a somewhat difficult environment, which is influx ... So bash -lc isn't really an option right now. My solution is similar to @Rocco, but it's a bit more refined.
# run a command in the `current` directory of `deploy_to`
def run_interactively(command)
  # select a random server to run on
  server = find_servers_for_task(current_task).sample
  # cobble together a shell environment
  app_env = fetch("default_environment", {}).map{|k,v| "#{k}=\"#{v}\""}.join(' ')
  # Import the default environment, cd to the currently deployed app, run the command
  command = %Q(ssh -tt -i #{ssh_options[:keys]} #{user}@#{server} "env #{app_env} bash -c 'cd #{deploy_to}/current; #{command}'")
  puts command
  exec command
end

namespace :rails do
  desc "rails console on a sidekiq worker"
  task :console, role: :sidekiq_normal do
    run_interactively "bundle exec rails console #{rails_env}"
  end
end

A: For a Rails console in Capistrano 3 see this gist: https://gist.github.com/joost/9343156

A: I have just used capistrano-rails-console gem to open rails console and it is working fine.


text:
Q: Integrate flex 3.5 projects in flash builder 4 beta 2 I'm currently using Flex Builder 3 and Flex SDK 3.5 for my projects. But I'd like to try out the new Flash Builder 4. So I downloaded and installed the new software, configured all the additional software like subversion, server adapter .. and finally a importet my 2 projects.
1) Main Project  (includes a swc generated by the Library Project) (flex sdk 3.5)
2) Library Project (flex sdk 3.4)
After the import and project cleanup the project is running perfectly. But as soon as I replace the existing LibraryProject.swc through a new one (compiled with flash builder 4 beta 2 sdk 3.4)
VerifyError: Error #1014: class mx.containers::Canvas not found.
VerifyError: Error #1014: class mx.containers::HBox not found.
VerifyError: Error #1014: class IWatcherSetupUtil not found.
... and several others not found errors.
Does anyone has the same error. How can I get my project running again?

A: I would first check the Properties of both project very carefully. Things that are important:
In your Main project (containing the actual Application)

*

*Flex Build Path -> Library Path Check if the import order is correct and try to change it according to your dependencies)

*Flex Compiler (check the SDK!)
In your Library

*

*Flex Library Build Path -> Classes (see if everything ic checked what you need, except if you are using MAVEN with flexmojos.

*Flex Library Build Path -> Library Path (again, the order is very important if you are using 3rd party stuff)
I take it that both, your application and your swc are built within the same IDE with the same SDK version. Of course, theoretically it should be downwards compatible, but thats only true in every case for some parallel universe :-).


text:
Q: At smaller sites, penalize hot questions having 3-4 close votes At smaller sites (up to 50-100 questions a day average) closing a question takes hours or even days.

*

*As an example, this SO question has got 5 close votes in 15 minutes, while its twin at Software Engineering (previously known as Programmers) has been struggling to get 3rd vote for over 10 hours. "Twin" here means, same question has been cross-posted at both sites, is equally inappropriate at both (tool recommendation), has comments explaining the issue for readers and is downvoted rather heavily, to -4 / -6.
Given above, suggest to take into account when there is a solid evidence that question may turn out inappropriate for the site and exercise more caution about promoting such questions in the hot list.
Penalize smaller sites questions having 3-4 close votes - say, cut their hotness score by half or drop them off the list completely. This will increase chances for less troublesome questions to enter hot list.
Indiscriminately advertising questions that are on their way to closure, with only 1-2 votes left to go hurts site community morale and dilutes the Stack Exchange brand:

watching the 'hot network questions' leads me to think that several of the recent sites are gigantic broken windows of self-absorbed subjectivity... The questions are whiney, the answers are opinion...

Consider also disappointment and frustration of new users coming to sites to ask questions similar to ones advertised in the hot list only to discover that these are voted down and closed as inappropriate (broken windows effect).

Related:

*

*Avoid tweeting bad questions

we won't tweet questions with close votes

*Reorder questions picked for hot list...

Close votes on the question should reduce the total hotness of the question by 20% (so a closed question would have a 0 hotness score)

*Better criteria for the hot questions list

Weight Flags/Close Votes Against Questions... 30% of our hot questions over the past month all got closed, which is less than ideal, because we want the attention to go to good polished questions rather than works in progress... If close votes count against the hotness score, then we can vote to close while trying to improve the post, and not worry about it getting a dozen answers in 24 hours as the entire SE network flocks in.

A: Additional reading for those thinking that advertising of close-worthy "entertaining" questions is harmless: The Trouble With Popularity

we discovered that these posts... truly start to drown out everything else on the site... it's too addictive and too easy, and in the absence of any moderation, the community would do nothing but add and upvote the easy, fun stuff. This is why community moderators have real power; they need that power to intervene, educate, and refocus the community's exuberance on more substantive content...

It is... sad to observe how mindless click-hunting obscures core values of our Q&A system.

One way to achieve what is requested here is to modify a step at which hot questions are shuffled to pick ones to go to sidebar.
At this step, questions with many votes to close could get "lower weight" in shuffling so that these will have less chances to be displayed at sidebar compared to less troublesome questions.
Performance wise, this doesn't look like a heavy load. The only noticeable difference from the way how things work now seems to be the need to additionally query small fixed amount of questions (100) to find out which of these have many votes to close.

Another option is for system to pick more than 100 (110, 120...) "candidates to the list" and then use data on close votes to decide which questions get to "final list" of 100. Performance load wise, this seems to be similar to the option discussed above.

A: This would be amazing for the Workplace.
We're frequently getting Hot Network Questions about some preposterous topic that will obviously get closed, but the HNQ drive by upvotes make it spiral out of control. Often times, these questions are sitting at 2-4 CVs when they enter HNQ.
It would go a long way towards mitigating the HNQ problem on sites like the Workplace if there was a penalty for pending close votes on HNQs.


text:
Q: cakephp ajaxhelper using jquery with multiple buttons I have the same issue that is expressed here: http://ask.cakephp.org/questions/view/multiple_submit_buttons_1
That page asked about the issue, but there was no solution posted that actually worked.
I have a cakephp ajax popup form with multiple buttons.  On the back end controller, when I look through the post values, the value of the button is not being sent.  This happens in all my ajax forms.  It doesn't pass the submit buttons as a form value.
My question is:  How can I get the form value of the submit button on the back end controller?  I had a solution that worked, but was quirky.  I added javascript to each of the submit buttons onclick event that set the value of a hidden input box named "form_action".

A: Set the name for the button:
echo $this->Form->submit('Reply',array('name'=>'data[Message][reply]'))