text:
Q: How to load dynamic HTML into DIV with component? Angular5 I have been trying to find the solution of this problem from two days. Unfortunately, I can not get what I want. I am using Angular5.

This is what my function looks like:
GetItemsOfHolder(item: any,divName:string, recursive: boolean = false,typeName:string="")
{
return html;
}

Everything works fine, unless The html which I am returning contains one package named Select2
This is what I use to add the html into this div it works very fine. Until I wanted to add the dynamic package.
What I mean is return html contains the package component like this:
itemhtml +="<select2 data-type='"+holderItem.itemType+"'
[data]='this.dropdownData."+holderItem.name+"'></select2>"

This just returns the plain text to the browser and doesn't work as expected.
What I want is the string to be turned into component or any other way which works and generates the select2 dropdown.
I have been trying to search so many things.But it doesn't works
This is good but I can not understand this   And dynamiccomponentloading is deprecated.
Can anyone please give me an idea How can I resolve this problem? Any example would be a great.

A: As commented by @Devcon

Angular will sanitize pretty much everything so that is why you are
  getting plain text. What you want to look into is ReflectiveInjector
  and mainly ComponentFactoryResolver. The main idea is that components
  need some other info(services, other components, etc) to be rendered,
  so you use the Injector to get Dependency Injection refs then the
  Component factory builds your component. You then insert this to a
  ViewChild reference. There is a more complicated way of dynamically
  making components that uses the compiler and requires a
  ModuleWithComponentFactories, this is what angular actually uses.

And searching on the angular, I accept that angular should not be done this way.
As I have to create the fully dynamic page which must be rendered in html. I changed my json little bit and using the
ng-container and ng-template and using ngswitch
I made recursive call in the template it self and found its working very fine.
I get many advantages using this:
The HTML (I render dynamically) itself is in HTML, Code is clean and readable, easily maitainable.
The example given here is pretty much the same I have done.
https://stackoverflow.com/a/40530244/2630817
A small example is here:
<ng-template #itemsList let-itemsList>

                {{item.label}}

              <input id="{{item.name}}" value="{{item.value}}" type='text' class='form-control txtbox ui-autocomplete-input'/>

                {{item.label}}

              <input id="{{item.name}}" value="{{item.value}}" type='password' class='form-control txtbox ui-autocomplete-input'/>

            {{item.label}}

<input id="{{item.name}}" type='checkbox' />

            {{item.label}}

                {{item.label}}

              <select2 class="form-control"  [data]="GetDropDowndata(item.holderId)" [cssImport]="false" [width]="300" [options]="GetOptions(item.type)"></select2>

A: You can load every you want in one div, you have to play with ng-template and ng-content.
First you have to create one directive:

import {Directive, ViewContainerRef} from '@angular/core';

@Directive({
  selector: '[dynamic]',
  exportAs: 'dynamicdirective'
})
export class DynamicDirective {

  constructor(public viewContainerRef: ViewContainerRef) { }

}

After you have to put it in some ng-template like:

  page works!

<ng-template #sider=dynamicdirective dynamic></ng-template>

and use it like

import {Component, ComponentFactoryResolver, OnInit, ViewChild} from '@angular/core';

@Component({
  selector: 'app-page',
  templateUrl: './page.component.html',
  styleUrls: ['./page.component.css']
})
export class PageComponent implements OnInit {

  @ViewChild('sider')
  sider;

  constructor(private componentFactoryResolver: ComponentFactoryResolver) {
  }

  ngOnInit() {

      const componentFactory = this.componentFactoryResolver.resolveComponentFactory(SomeComponent);
 this.sider.viewContainerRef.createComponent(componentFactory);
    });

  }

}

and normally will see you component loaded at the place of you ng-template (you can call https://angular.io/api/core/ViewContainerRef#clear if you want to reset your view)
I already play with this, you can find some code here https://github.com/nicearma/dynamic

A: I thought to leave this here for anyone who encounters the same issue in the future.
If you don't want to bother manually instantiating components with ComponentFactory as the other answers suggest, you can also use a library I wrote for the explicit purpose of loading components into dynamic content: ngx-dynamic-hooks.
You can give it any string that contains the selector of a desired component and it will automatically be loaded in its place. You can even load components by other text patterns other than just their selectors! See it in action in this Stackblitz.
There's a lot more bells and whistles, if you need them. In the link above, you'll find a fairly detailed documentation that should set you up easily.


text:
Q: Ionic 3 - App stuck on splashscreen. Starts running once I make a change and refreshes while emulating (iOS) Have an Ionic 3 app, that gets stuck on splash screen when I'm emulating on iOS. Funny thing, if I add a space to a ts file, it refreshes and starts working.

This is messing up my E2E testing with Appium, so I'm wondering if anyone has a better idea of what might be causing this behaviour.
I'm leaving here all package.json dependencies, in case that helps:
"dependencies": {
"@angular/animations": "^4.0.0",
"@angular/cdk": "^2.0.0-beta.12",
"@angular/common": "5.0.0",
"@angular/compiler": "5.0.0",
"@angular/compiler-cli": "5.0.0",
"@angular/core": "5.0.0",
"@angular/forms": "^5.0.0",
"@angular/http": "5.0.0",
"@angular/platform-browser": "5.0.0",
"@angular/platform-browser-dynamic": "5.0.0",
"@ionic-native/aes-256": "^4.20.0",
"@ionic-native/battery-status": "^4.9.0",
"@ionic-native/core": "^4.10.1",
"@ionic-native/device": "^4.17.0",
"@ionic-native/dialogs": "^4.9.0",
"@ionic-native/file": "^4.9.0",
"@ionic-native/file-chooser": "^4.10.0",
"@ionic-native/file-path": "^4.10.0",
"@ionic-native/file-transfer": "^4.20.0",
"@ionic-native/http": "^4.10.0",
"@ionic-native/insomnia": "^4.9.2",
"@ionic-native/keyboard": "^4.15.0",
"@ionic-native/local-notifications": "^4.9.0",
"@ionic-native/media": "^4.9.0",
"@ionic-native/network": "^4.17.0",
"@ionic-native/power-management": "^4.9.2",
"@ionic-native/pro": "^4.9.2",
"@ionic-native/screen-orientation": "^4.20.0",
"@ionic-native/splash-screen": "4.3.2",
"@ionic-native/status-bar": "4.3.2",
"@ionic/pro": "^2.0.3",
"@ionic/storage": "2.1.3",
"@types/crypto-js": "^3.1.43",
"awesome": "0.0.7",
"bootstrap": "^4.0.0-beta.2",
"cordova-ios": "5.0.0",
"cordova-plugin-advanced-http": "^1.11.1",
"cordova-plugin-android-permissions": "^1.0.0",
"cordova-plugin-background-upload": "^1.0.12",
"cordova-plugin-badge": "0.8.8",
"cordova-plugin-battery-status": "^2.0.2",
"cordova-plugin-device": "^2.0.2",
"cordova-plugin-dialogs": "^2.0.1",
"cordova-plugin-file": "^6.0.1",
"cordova-plugin-file-transfer": "^1.7.1",
"cordova-plugin-filechooser": "^1.2.0",
"cordova-plugin-filepath": "^1.5.1",
"cordova-plugin-insomnia": "^4.3.0",
"cordova-plugin-ionic": "^5.3.0",
"cordova-plugin-ionic-keyboard": "^2.1.3",
"cordova-plugin-ionic-webview": "^2.3.1",
"cordova-plugin-ios-camera-permissions": "^1.2.0",
"cordova-plugin-ios-disableshaketoedit": "^1.0.0",
"cordova-plugin-itunesfilesharing": "0.0.1",
"cordova-plugin-local-notification": "0.9.0-beta.2",
"cordova-plugin-media": "^5.0.2",
"cordova-plugin-network-information": "^2.0.1",
"cordova-plugin-powermanagement-orig": "^1.1.2",
"cordova-plugin-screen-orientation": "^3.0.1",
"cordova-plugin-splashscreen": "^5.0.2",
"cordova-plugin-statusbar": "^2.4.2",
"cordova-plugin-whitelist": "^1.3.3",
"crypto-js": "^3.1.9-1",
"es6-promise-plugin": "^4.2.2",
"font-awesome": "4.7.0",
"hammerjs": "^2.0.8",
"ionic-angular": "3.9.2",
"ionic-native-datepicker": "^1.0.5",
"ionicons": "3.0.0",
"ios-sim": "^8.0.2",
"jquery": "3.3.1",
"jwt-decode": "^2.2.0",
"ngx-dropdown-list": "^1.1.1",
"ngx-infinite-scroll": "^0.8.3",
"ngx-pagination": "^4.1.0",
"ngx-select-dropdown": "^1.0.1",
"node-sass": "4.9.0",
"rxjs": "5.5.2",
"sw-toolbox": "3.6.0",
"web-animations-js": "^2.3.1",
"zone.js": "0.8.18"
},
"devDependencies": {
    "@angular/cli": "^1.5.0",
    "@angular/router": "^4.4.6",
    "@ionic/app-scripts": "^3.2.4",
    "@types/jasmine": "^2.6.3",
    "@wdio/appium-service": "^6.4.0",
    "@wdio/cli": "^6.4.2",
    "@wdio/local-runner": "^6.4.2",
    "@wdio/mocha-framework": "^6.4.0",
    "@wdio/selenium-standalone-service": "^6.4.0",
    "@wdio/spec-reporter": "^6.4.0",
    "@wdio/sync": "^6.4.0",
    "appium": "^1.18.1",
    "appium-doctor": "^1.15.3",
    "chromedriver": "^84.0.1",
    "ionic-mocks": "^0.13.0",
    "jasmine-core": "^2.8.0",
    "jasmine-spec-reporter": "^4.2.1",
    "karma": "^1.7.1",
    "karma-chrome-launcher": "^2.2.0",
    "karma-cli": "^1.0.1",
    "karma-coverage-istanbul-reporter": "^1.3.0",
    "karma-jasmine": "^1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "karma-junit-reporter": "^1.2.0",
    "protractor": "^5.1.2",
    "sass-loader": "^6.0.7",
    "ts-node": "^3.3.0",
    "tslint-eslint-rules": "^4.1.1",
    "typescript": "^2.4.2",
    "wdio-appium-service": "^0.2.3",
    "wdio-chromedriver-service": "^6.0.3",
    "wdio-jasmine-framework": "^0.3.8",
    "wdio-mochawesome-reporter": "^4.0.0",
    "wdio-spec-reporter": "^0.1.5",
    "webdriverio": "^6.4.2",
    "ws": "3.3.2"
  },

BTW, already tried the following:

*

*Removing platform and building again
 ionic cordova platform rm ios
 ionic cordova platform add ios@5.0.0
 ionic cordova emulate ios -lc --target iPad--6th-generation-

*When preparing/building I have a different issue:
 ionic-app-script task: "build"
 Error: Failed to transpile program
 at new BuildError ([...]/node_modules/@ionic/app-scripts/dist/util/errors.js:16:28)

A: Ok, basically there was a conflict  between Ionic and Appium dependencies.
Spent a few hours trying to crack that, but opted for moving appium implementation along with E2E tests to a separate folder.

A: Clean and rebuild
ionic clean
ionic build

redpajama_set_name: RedPajamaStackExchange


text:
Q: Shiny app - conditional selection I have a basic Shiny app that display results (4 columns) with the possibility of filtering out some of the results.
These columns are interconnected through a hierarchy:

*

*ProductCategory (furniture, food, ...)

*ProductType (table, oranges, apples, ...)

*ProductColor (yellow, green, ...)

The data table I'm using looks like this
Product Category --- ProductType --- ProductColor
When I select one product category, let's say fruit, I can still see in the product type selection box the instance "table". So I would want to restrict what I see in one box with what I have selected in another box. Is that possible? I'm quite new to R and Shiny and I'm not sure that I'm using the right terminology to google the issue.
library(shiny)
library(ggplot2)
library(shinydashboard)
library(DT)

ui<-fluidPage(
    titlePanel("Product catalogue"),

    # Create a new Row in the UI for selectInputs
    fluidRow(
      column(4,
             selectInput("ProductCategory",
                         "ProductCategory:",
                         c("All",
                           unique(as.character(Prod$ProductCategory))))
      ),
      column(4,
             selectInput("ProductType",
                         "ProductType:",
                         c("All",
                           unique(as.character(Prod$ProductType))))
      ),
      column(4,
             selectInput("ProductColor",
                         "ProductColor:",
                         c("All",
                           unique(as.character(Prod$ProductColor))))
      )
    ),
    # Create a new row for the table.
    fluidRow(
      DT::dataTableOutput("table")
    ))
server<- function(input, output) {

    # Filter data based on selections
    output$table <- DT::renderDataTable(DT::datatable({
      data <- Prod
      if (input$ProductCategory!= "All") {
        data <- data[data$ProductCategory== input$ProductCategory, ]
      }
      if (input$ProductType!= "All") {
        data <- data[data$ProductType== input$ProductType,]
      }
      if (input$ProductColor!= "All") {
        data <- data[data$ProductColor == input$ProductColor,]
      }
      data
    })

Fixed integrating the previous code with this: this solution


text:
Q: Shader without loosing self background color? Is it possible to apply a shader while preserving the self color?
so far this is what I've come up with
shader_type canvas_item;

void fragment(){
    vec4 self_color = texture(TEXTURE, UV);
    vec4 back_color = texture(SCREEN_TEXTURE, SCREEN_UV);

    if(self_color.a==0.0)
        COLOR=back_color;
    else // invert color
        COLOR = mix(self_color,vec4(1.0 - back_color.rgb, back_color.a),0.5);
}

but as you can see (on left) it's faded and merges with the editor's gray background
as compared to the original image (on right)

This is what I'm trying to achieve:

A: The only thing that comes to mind is to tell the shader what the clear color is and use that for reference. Something like the following (I'm not sure if this is the desired effect, but hopefully you can tweak to what you want):
shader_type canvas_item;
uniform vec4 clear_color:hint_color;

void fragment(){
    vec4 self_color = texture(TEXTURE, UV);
    vec4 back_color = texture(SCREEN_TEXTURE, SCREEN_UV);

    COLOR = mix
    (
        self_color,
        mix(self_color, back_color, 0.5),
        distance(back_color, clear_color)
    );
}

Here I'm mixing colors based on how far are the background is from the clear color distance(back_color, clear_color)※. When they match, you should get self_color, and as they differ the mix would approach mix(self_color, back_color, 0.5) (tweak that to your needs).
※: You can try other metrics, for example dot(back_color - clear_color, back_color - clear_color) or dot(abs(back_color - clear_color), vec4(1.0)).


text:
Q: Algorithm - Handling Jitter and Drift with External Codec/Modem I am writing a small module in C to handle jitter and drift for a full-duplex audio system. It acts as a very primitive voice chat module, which connects to an external modem that uses a separate clock, independent from my master system clock (ie: it is not slaved off of the system master clock).
The source is based off of an existing example available online here: http://svn.xiph.org/trunk/speex/libspeex/jitter.c
I have 4 audio streams:

*

*Network uplink   (my voice, after processing, going to the far side speaker)

*Network downlink (far side's voice, before processing, coming to me)

*Speaker output   (the far side's voice, after processing, to the local speakers)

*Mic input        (my voice, before processing, coming from the local microphone)

I have two separate threads of execution. One handles the local devices and buffer (ie: playing processed audio to the speakers, and capturing data from the microphone and passing it off to the DSP processing library to remove background noise, echo, etc). The other thread handles pulling the network downlink signal and passing it off to the processing library, and taking the processed data from the library and pushing it via the uplink connection.
The two threads use mutexes and a set of shared circular/ring buffers. I am looking for a way to implement a sure-fire (safe and reliable) jitter and drift correction mechanism. By jitter, I am referring to a clock having variable duty cycle, but the same frequency as an ideal clock.

The other potential issue I would need to correct is drift, which would assume both clocks use an ideal 50% duty cycle, but their base frequency is off by ±5%, for example.

Finally, these two issues can occur simultaneously. What would be the ideal approach to this? My current approach is to use a type of jitter buffer. They are just data buffers which implement a moving average to count their average "fill" level. If a thread tries to read from the buffer, and not-enough data is available and there is a buffer underflow, I just generate data for it on-the-fly by either providing a spare zeroed-out packet, or by duplicating a packet (ie: packet loss concealment). If data is coming in too quickly, I discard an entire packet of data, and keep going. This handles the jitter portion.
The second half of the problem is drift correction. This is where the average fill level metric comes in useful. For all buffers, I can calculate the relative growth/reduction levels in various buffers, and add or subtract a small number of samples every so often so that all buffer levels hover around a common average "fill" level.
Does this approach make sense, and are there any better or "industry standard" approaches to handling this problem?
Thank you.
References

*

*Word Clock – What's the difference between jitter and frequency drift?, Accessed 2014-09-13, <http://www.apogeedigital.com/knowledgebase/fundamentals-of-digital-audio/word-clock-whats-the-difference-between-jitter-and-frequency-stability/>

*Jitter.c, Accessed 2014-09-13, <http://svn.xiph.org/trunk/speex/libspeex/jitter.c>

A: I am curious to see if this is possible. I'll throw in my two bits though.
I am a novice programmer, but studied audio engineering/interactive audio.
My first assumption is that this is not possible. At least not on a sample-to-sample basis.  Especially not for complex audio data and waveforms such as human speech.  The program could have no expectation of what the waveform "should" look like.
This is why there are high-end audio interfaces with temperature controlled internal clocks.
On the other hand, maybe there is a library that can detect the symptoms of jitter, somehow...
   In which case I would be very curious to hear about it.
As far as drift correction, maybe I don't understand something on the programming front, but shouldn't you be pulling audio at a specific sample rate?  I believe sample rate/drift is handled at the hardware level.
I really hope this helps.  You might have to steer me closer to home.

A: I faced a similar, although admittedly simpler, problem. I won't be able to fully answer your question but i hope sharing my solutions to some practical problems i ran into will benefit you anyway.
Last year i was working on a system which should simultaneously record from and render to multiple audio devices, each potentially ticking off a different clock. The most obvious example being a duplex stream on 2 devices, but it also handled multiple inputs/outputs only. All in all being a bit simpler than your situation (single threaded and no network i/o). In the end i don't believe dealing with more than 2 devices is harder than 2, any system with multiple clocks is going to have to deal with the same problems.
Some stuff i've learned:

*

*Pick one stream and designate it's clock as "the truth" (i.e., sync all other streams to a common master clock). If you don't do this you won't have a well-defined notion of "current sample position", and without it there's nothing to sync to. This also has the benefit that at least one stream in the system will always be clean (no dropping/padding samples).

*Your approach of using an additional buffer to handle jitter is correct. Without it you'd be constantly dropping/padding even on streams with the same nominal sample rate.

*Consider whether or not you'd want to introduce such a jitter buffer for the "master" stream also. Doing so means introducing artificial latency in the master stream, not doing so means the rest of your streams will lag behind.

*I'm not sure whether it's a good idea to drop entire packets. Why not try to use up as much of the samples as possible? Especially with large packet sizes this is far less noticeable.

*To elaborate on the above, I got badly bitten by the following case: assume s1 (master) producing 48000 frames every second and s2 producing 96000 every 2 seconds. Round 1: read 48000 from s1, 0 from s2. Round 2: read 48000 from s1, 96000 from s2 -> overflow. Discard entire packet. Round 3: read 48000 from s1, 0 from s2. Etc. Obviously this is a contrived example but i ran into cases where on average I dropped 50% of secondary stream's data using this scheme. Introduction of the jitter buffer does help but didn't completely fix this problem. Note that this is not strictly related to clock jitter/skew, it's just that some drivers like to update their padding values periodically and they will not accurately report to you what is really in the hardware buffer.

*Another variation on this problem happens when you really do got clock jitter but the API of your choice doesn't let you control packet size (e.g., allows you to request less frames than are actually available). Assume s1 (master) recording @1000 Hz and s2 alternating each second @1000 and 1001hz. Round 1, read 1000 frames from both. Round 2, read 1000 frames from s1, and 1001 from s2 -> overflow. Etc, on average you'll dump around 50% of frames on s2. Note that this is not so much a problem if your API lets you say "give me 1000 samples even though i know you've got more". By doing so though, you'll eventually overflow the hardware input buffer.

*To have the most control over when to drop/pad, I found it easiest to allways keep input buffers empty and output buffers full. This way all dropping/padding takes place in the jitter buffer and you'll at least know and control what's happening.

*If possible try to separate your program logic: the hard part is finding out where to pad/drop samples. Once you've got that in place it's easy to try different variations of pad/drop, sample-and-hold, interpolation etc.

All in all I'd say your solution looks very reasonable, although I'm not sure about the "drop entire packet thing" and I'd definitely pick one stream as the master to sync against. For completeness here's the solution I eventually came up with:

*

*1 Assume a jitter buffer of size J on each stream.

*2: Wait for a packet of size M to become available on the master stream (M is typically derived from the stream latency). We're going to deliver M frames of input/output to the app. I didn't implement an additional buffer on the master stream.

*3: For all input streams: let H be the number of recorded frames in the hardware buffer, B be the number of recorded frames currently in the jitter buffer, and A being the number of frames available to the application: A equals H + B.

*3a: If A < M, we have input underflow. Offer A recorded frames + (M - A) padding frames to the app. Since the device is likely slow, fill 1/2 of the jitter buffer with silence.

*3b: If A == M, offer A frames to the app. The jitter buffer is now empty.

*3c: If A > M but (A - M) <= J, offer M recorded frames to the app. A - M frames stay in the jitter buffer.

*3d: If A > M and (A - M) > J, we have input overflow. Offer M recorded frames to the app, of the remaining frames put J/2 back in the jitter buffer, we use up M + J/2 frames and we drop A - (M + J/2) frames as overflow. Don't try to keep the jitter buffer full because the device is likely fast and we don't want to overflow again on the next round.

*4: Sort of the inverse of 3: for outputs, fast devices will underflow, slow devices will overflow.
A, H and B are the same thing but this time they don't represent available frames but available padding (e.g., how much frames can i offer to the app to write to).
Try to keep hardware buffers full at all costs.

This scheme worked out quite well for me, although there's a few things to consider:

*

*It involves a lot of bookkeeping. Make sure that for input buffers, data always flows from hardware->jitter buffer->application and for outputs always from app->jitter buffer->hardware. It's very easy to make the mistake of thinking you can "skip" frames in the jitter buffer if there's enough samples available from the hardware directly to the app. This will essentially mess up the chronological order of frames in an audio stream.

*This scheme introduces variable latency on secondary streams because i try to postpone the moment of padding/dropping as long as possible. This may or may not be a problem. I found that in practice postponing these operations gives audibly better results, probably because many "minor" glitches of only a few samples are more annoying than the occasional larger hiccup.

Also, PortAudio (an open source audio project) has implemented a similar scheme, see http://www.portaudio.com/docs/proposals/001-UnderflowOverflowHandling.html. It may be worthwile to browse through the mailinglist and see what problems/solutions came up there.
Note that everything i've said so far is only about interaction with the audio hardware, i've no idea whether this will work equally well with the network streams but I don't see any obvious reason why not. Just pick 1 audio stream as the master and sync the other one to it and do the same for the network streams. This way you'll end up with two more-or-less independent systems connected only by the ringbuffer, each with an internally consistent clock, each running on it's own thread. If you're aiming for low audio latency, you'll also want to drop the mutexes and opt for a lock-free fifo of some sorts.


text:
Q: How to keep the DetailsView of a SfDataGrid expanded? I have a SfDataGrid and I made a DetailsViewDefinition for that. I also make ExpandAllDetailsView from code to expand all details and I want to keep these open, but right after the first reorder or first regroup these will collapse.
I tried kinda every events (what made sense) to reopen, but only the MouseUp was the closest to the goal, but that was kinda bad because it does not work on header and will reopen on every mouseups, so it was a very bad hack.
I would like to know a good and working way to keep the rowdetail open even after events like reorder/group.

A: You can achieve your requirement by using SfDataGrid.ExpandAllDetailsView method. For grouping, you can achieve this by SfDataGrid.GroupColumnDescriptions.CollectionChanged event,
this.dataGrid.GroupColumnDescriptions.CollectionChanged += GroupColumnDescriptions_CollectionChanged;
private void GroupColumnDescriptions_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
 {
dataGrid.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.ApplicationIdle,
          new Action(() =>
          {
              this.dataGrid.ExpandAllDetailsView();
          }));
 }

For sorting you can achieve this by SfDataGrid.SortColumnsChanged event,
this.dataGrid.SortColumnsChanged += DataGrid_SortColumnsChanged;

private void DataGrid_SortColumnsChanged(object sender, GridSortColumnsChangedEventArgs e)
{
    dataGrid.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.ApplicationIdle,
         new Action(() =>
         {
             this.dataGrid.ExpandAllDetailsView();

         }));
}

Sample
Regards,
Susmitha S


text:
Q: Explanation for important reserved space I am analysing a database
I didn't understand why reserved space is more important then used space ?
Any explication ? can I get 400 GO ?

A: Space Reserved is the size you setup using either:

*

*SSMS = Database Properties / Files Database file / Initial Size (MB)

*Alter Database [XXX] MODIFY FILE ( NAME = N'XXX', SIZE = ...KB)

*Autogrowth changes it as well

You can check these setting using SSMS or this query:
SELECT file_id, name, type_desc, physical_name, size = size/128, max_size = max_size/128
FROM sys.database_files ;

Space Used is the size of your existing data pages in your data file. You can use this query:
SELECT name, groupid, filename,
   Cast(size/128.0 AS DECIMAL(10,2)) AS [Allocated MB],
   Cast(FILEPROPERTY(name, 'SpaceUsed')/128.0 AS DECIMAL(10,2)) AS [Used MB],
   Cast([maxsize]/128.0 AS DECIMAL(10,2)) AS [Max Size MB],
   Cast([maxsize]/128.0-(FILEPROPERTY(name, 'SpaceUsed')/128.0) AS DECIMAL(10,2)) AS [Available Space in MB]
FROM sysfiles
ORDER BY groupid DESC


text:
Q: General question on $\epsilon$ and choice of $a$ and $b$ Well I do have a small understanding issue here.
If you say that for every  $\epsilon > 0$ there are two values $a, b \in \mathbb{R}$ with $a \neq b$ such that $ a - b  < \epsilon$. Thats not a problem there.
But when you say that there are two fixed values $x,y \in \mathbb{R}$ such that $x-y < \epsilon$ for every $\epsilon > 0$. How does this not imply that $x = y$ ?
I mean in the upper case you can choose $a = b+\frac{\epsilon}{2}$ or something. But in the second case you already got two fixed values which are so close together that the difference is smaller than every $\epsilon > 0$. We had that in class and the lecturer told as it does not necessary mean that $x = y$.

A: If, for instance, $x=0$ and $y=1$, then it is true that, for every $\varepsilon>0$, $x-y<\varepsilon$. However, $x\neq y$.
You would be right if the condition was $|x-y|<\varepsilon$.


text:
Q: c# Remove parts of string from label inside an datalist Im working on a small news applicaton and im trying to remove parts of a text from a label inside a datalist, here is my code
<asp:DataListID="itemListNews"runat="server">
       <ItemTemplate>

                <%#DataBinder.Eval(Container.DataItem,"author") %>
                <asp:Label ID="lbTest" runat="server" class="news-text"><%#DataBinder.Eval(Container.DataItem,"news") %></asp:Label>

       </ItemTemplate>

I have been trying a couple of things and i keep getting the error message: startIndex must be less than the length of the string.Parameter name: startIndex
foreach (DataListItem item in itemListNews.Items)
    {
        Label lbtest = (Label) item.FindControl("lbTest");
        lbtest.Text.Remove(10);
    }

Any suggestions would be helpful

A: First you should test your string size is bigger than 10, Also at last assign new value:
if (lbtest.Text != null && lbtest.Text.Length > 10)
{
  lbtest.Text = lbtest.Text.Remove(10);
}

Doing just lbtest.Text.Remove(10); doesn't do anything (string is immutable, so you should reassign it).


text:
Q: What is the correct way to loop through this block? I have this block inside rails console.
@idea = Idea.find_by(rand(1...Idea.count))
@roundid = Faker::Number.between(1, 3)
@idea.round_id = @roundid

I am trying trying to update seven database rows. And I have used a code below.
7.times do
 @idea = Idea.find_by(rand(1...Idea.count))
 @roundid = Faker::Number.between(1, 3)
 @idea.round_id = @roundid
end

it does not do what I expect. Thoughts?

A: If you're just trying to randomly grab an Idea each time, you can use the more expressive Idea.all.sample.
To grab a random number, you also don't necessarily need Faker, you can just do rand(3) + 1.
If round_id is a column in the ideas table, you'll need to actually save the model on each iteration for the changes you're making to persist.
One faster way you could do this is:
Idea.all.sample(7).each do |idea|
   idea.update(round_id: rand(3) + 1)
end

This grabs 7 random Ideas, iterates over them, and assigns each a random round_id between 1 and 3.


text:
Q: Getting a sum from ArrayList using non-loop recursion I am working on this lab assignment for school and I was wondering if anyone could give me some advice. My instructor wants us to add different number objects up from an array list and display the result. He wants us to do the addition in a non-loop recursive format. I've done a similar problem like this before with just integers, but I cannot seem to get this solution because there is more than one primitive type this time. Here is the Code I have so far:
Main:
import java.math.BigInteger;
import java.util.ArrayList;

public class TestSummation {

public static void main(String[] args) {
    ArrayList<Number> aList = new ArrayList<Number>();
    aList.add(new Integer(4));
    aList.add(new Double(3.423));
    aList.add(new Float(99.032));
    aList.add(new BigInteger("32432"));
    double result = Summation.sum(aList);
    System.out.println(result);

}

}

Class that holds the recursive method:
import java.util.ArrayList;

public class Summation {

public static double sum(ArrayList<Number> aList) {

    if (aList.size() < 1) {
        return 0;
    } else {
        return sum(aList);
    }

}

}

Right now this code throws a StackOverflowException and I was wondering if anyone had advice that would help me. I definitely know I need to add more to it, but I feel I'm on the right track with this current section of code. I'm just hitting a bad roadblock right now. Thanks in advance for any advice!

A: Recursion always works by cons two different cases:

*

*the base case which is used to end the recursion

*the recursive case which is applied on a specific N-th step

By thinking about your problem you can consider as your base case either a list of size 1 or a list of size 0. Let's choose the first for simplicity: the sum of all values of a list of size 1 is the only value that it is contained.
Now let's look for the recursive case: suppose that the list has length N. What we know is that the sum of all elements of a list of N elements is the N-th element added to the sum of a list containing N-1 elements (by removing the N-th element). It's pretty self explicatory as most of recursive implementations.
As you can see the recursive step reduces the size of the list so that the algorithm step-by-step reaches the base case, this is not what is happening to your code.

A: Since you've done something similar with integers, I gather that the problem is how to deal with the multitude of number class types. Since you want a double result and all Number objects must implement a doubleValue() method, you can use that to build your recursion. To recurse, you need to take the first element's value and add it to the (recurive) summation of the sublist that starts with the second element:
public class Summation {
    public static double sum(List<Number> aList) {
        final int len = aList.size();
        if (len == 0) {
            return 0;
        }
        final double val = aList.get(0).doubleValue();
        if (len == 1) {
            return val;
        }
        // help future compilers recognize tail recursion
        return val + sum(aList.sublist(1, len));
    }
}

A: Well, without giving it all away, I'll tell you that your code is throwing the exception because you're not modifying the list at all, simply passing it back into your recursive method, which is resulting in an infinite loop. The bit you'll have to add involves modifying the list before passing it into the recursive call (and, of course, doing the actual summation).


text: Q: How is cross-validation used for logistic regression? I have a fundamental question about cross-validation in logistic regression. I would really appreciate some help since something is still unclear to me. My situation is the following: I split my data set into training, validation and test set. When using for example rpart for classification trees on a training set, it automatically splits it into k-folds (basically creating a validation set) and suggests an optimal complexity parameter. I can then run the suggested tree on my test set. However, if I run a logistic regression. Let's say I run a stepwise regression model (although I know stepwise regression model have to be used with caution). How can I use cross-validation to improve my model? Since, by using different folds, I will get models with different numbers of features. How can I choose one to eventually run it on my test set? Thank you very much in advance!


text:
Q: addresses from Geocoder size is always zero i have the problem as this question and i also did the same hardcoding for the lat and lon.
i get the exception to confirm the size as
Exception for the locationjava.lang.IndexOutOfBoundsException: Invalid index 0, size is 0

When I try the same code on the Redmi a4, it works fine and give me the size as 1, and also the geocoding works fine, returning me all the addresses. The same code when I run on Lenovo it gives the exception. I checked the lat and lon and they have values which when i trace is pointing to my location. So what should I do to make the app run on both of the phones.
Lenovo phone running Android 4.4.4
Redmi running 6.0.0
if(lat != null && lon !=null) {
        try{

       Geocoder geocoder;
        List<Address> addresses;
        geocoder = new Geocoder(this, Locale.getDefault());
        addresses = geocoder.getFromLocation(dlat, dlon, 1); // Here 1 represent max location result to returned, by documents it recommended 1 to 5
        System.out.println("this is the size of address size"+addresses.size());
         String address = addresses.get(0).getAddressLine(0); // If any additional address line present than only, check with max available address lines by getMaxAddressLineIndex()
        String city = addresses.get(0).getLocality();
        String state = addresses.get(0).getAdminArea();
        String country = addresses.get(0).getCountryName();
        String postalCode = addresses.get(0).getPostalCode();
        String knownName = addresses.get(0).getFeatureName();
        complete_address=address + "_" + city + "_" + address + "_" + postalCode + "_" + knownName + "_" + country;
        txtOutputLat.setText(complete_address);
        txtOutputLon.setText("Map Address");
    }
        catch(Exception e)
        {
            System.out.println("Exception for the location"+e.toString());

        }
    }

A: Create this class and copy the code this works perfectly for me also this works in background and stops the main thread from ANR dialog
 import android.content.Context;
 import android.location.Address;
 import android.location.Geocoder;
 import android.os.AsyncTask;

 import java.io.IOException;
 import java.util.List;
 import java.util.Locale;

public class GetLocationAsync extends AsyncTask<String, Void, String> {
private String fulladdress = "";
private String smallAddress = "";
private String city = "";
private String state = "";
private String country = "";
private String zipcode = "";
private String placeName = "";

private AsyncResponse asyncResponseDelegate = null;
private   double x, y;
private Context context;

public interface AsyncResponse {
    void onProcessFinished(String fulladdress, String smallAddress, String state, String city, String country, String zipCode, String placeName);
}

public GetLocationAsync(double latitude, double longitude, final Context context, AsyncResponse asyncResponse) {
    x = latitude;
    y = longitude;
    this.context = context;
    this.asyncResponseDelegate = asyncResponse;
}

@Override
protected void onPreExecute() {
}

@Override
protected String doInBackground(String... params) {
    Geocoder geocoder = new Geocoder(context, Locale.ENGLISH);
    try {
        List<Address> addressList = geocoder.getFromLocation(x, y, 1);
        StringBuilder sb = new StringBuilder();
        if (addressList != null && addressList.size() > 0) {
            Address address = addressList.get(0);
            fulladdress = "";
            smallAddress = "";
            placeName = "";
            if (sb.append(address.getAddressLine(0)) != null) {
                smallAddress = address.getAddressLine(0);
                fulladdress = smallAddress;
            }
            if (address.getLocality() != null) {
                city = address.getLocality();
                if (!fulladdress.contains(city))
                    fulladdress = fulladdress + " " + city;
            }
            if (address.getFeatureName() != null) {
                placeName = address.getFeatureName();
            }
            if (address.getAdminArea() != null) {
                state = address.getAdminArea();
                if (!fulladdress.contains(state))
                    fulladdress = fulladdress + " " + state;
            }
            if (address.getPostalCode() != null) {
                zipcode = address.getPostalCode();
                if (!fulladdress.contains(zipcode))
                    fulladdress = fulladdress + " " + zipcode;
            }
            if (address.getCountryName() != null) {
                country = address.getCountryName();
                if (!fulladdress.contains(country))
                    fulladdress = fulladdress + " " + country;
            }
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    return null;
}

@Override
protected void onPostExecute(String result) {
    try {
        if (fulladdress != null && !fulladdress.isEmpty()) {
            asyncResponseDelegate.onProcessFinished(fulladdress, smallAddress, state, city, country, zipcode, placeName);
        } else {
            asyncResponseDelegate.onProcessFinished("", "", "", "", "", "", "");
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 }

to call this class
  GetLocationAsync locationAsync = new GetLocationAsync(latitude,
                                        longitude, getActivity(), new    GetLocationAsync.AsyncResponse() {
                                    @Override
                                    public void onProcessFinished(String fulladdress, String smallAddress, String state, String city, String country, String zipCode, String placeName) {
                                        etAddress.setText(fulladdress);
                                    }
                                });
                                locationAsync.execute();

A: What happens is when you try to get the postal code,city,country etc etc only from the address is that you might not recieve it for the very first time since its trying to get all zipcode, country, state and city from a single provider, which may not be available at times. Instead if you loop through the providers you may find it in one of them. Try this hope it helps!
               List<Address> addresses  = null;
                    try {
                        addresses =geocoder.getFromLocation(latitude,longitude, 5);

                        if (addresses.size() > 0) {

                            zipCode = addresses.get(0).getPostalCode();
                            city = addresses.get(0).getLocality();
                            country = addresses.get(0).getCountryName();
                            state = addresses.get(0).getAdminArea();
                            address = addresses.get(0).getAddressLine(0);
                            knownName = addresses.get(0).getFeatureName();

                            //if 1st provider does not have data, loop through other providers to find it.
                            int count = 0;
                            while ( count < addresses.size()) {
                                zipCode = addresses.get(count).getPostalCode();
                                    city= addresses.get(count).getLocality();
                            country = addresses.get(count).getCountryName();
                            state = addresses.get(count).getAdminArea();
                             address = addresses.get(count).getAddressLine(0);
                            knownName = addresses.get(count).getFeatureName();

                                count++;
                            }
                        }

                    } catch (IOException e) {
                        e.printStackTrace();
                    }

A: Check for internet connection before calling geocoder.
    if(isConnectingToInternet(getContext()){
      //write your code of calling geocoder
     }

   public boolean isConnectingToInternet(Context context) {
    try {
        if (context != null) {
            ConnectivityManager connectivity = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
            if (connectivity != null) {
                NetworkInfo[] info = connectivity.getAllNetworkInfo();
                if (info != null)
                    for (int i = 0; i < info.length; i++)
                        if (info[i].getState() == NetworkInfo.State.CONNECTED) {
                            return true;
                        }
            }
        }
    } catch (Exception e) {
       e.printStacktrace
    }
    return false;
}


text:
Q: ImportError when importing spaCy using Spyder I'm still new to Python. I'm having issues when importing spaCy in python (v2.7) which doesn't appear when using it in ipython (v5.4.1). I used to have spaCy 2.0.11 then I reinstalled 2.0.7 and the issue remains.
Some useful info about the spaCy model and python version I have :
Python version     2.7.14
    Platform           Darwin-15.5.0-x86_64-i386-64bit
    spaCy version      2.0.7
    Location           /Users/AMAL/anaconda2/lib/python2.7/site-packages/spacy
    Models             en_core_web_sm, en_default

Thinc version:
Name: thinc
Version: 6.10.2

Doing import spacy and other imports using ipython doesnt cause any problems, and when using python interpreter in terminal:
python
Python 2.7.14 |Anaconda custom (64-bit)| (default, Oct  5 2017, 02:28:52)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import spacy
>>> import thinc
>>> import thinc.neural
>>> from thinc.neural.util import copy_array
>>> exit()

This is my code:
import re
import string
import math
from itertools import chain
from spacy.en import English '''Error triggered here'''

However, using Spyder IDE first throws this error:
  File "/Users/AMAL/anaconda2/lib/python2.7/distutils/command/build_ext.py", line 499, in build_extension
    depends=ext.depends)

  File "/Users/AMAL/anaconda2/lib/python2.7/distutils/ccompiler.py", line 574, in compile
    self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)

  File "/Users/AMAL/anaconda2/lib/python2.7/distutils/unixccompiler.py", line 124, in _compile
    raise CompileError, msg

ImportError: Building module thinc.neural.optimizers failed: ['ImportError: Building module thinc.neural.ops failed: ["CompileError: command \'gcc\' failed with exit status 1\\n"]\n']

Then in the second compile the error is changed and remains the same:
Traceback (most recent call last):

  File "<ipython-input-3-3743c1a24668>", line 1, in <module>
    runfile('/Users/AMAL/p1', wdir='/Users/AMAL')

  File "/Users/AMAL/anaconda2/lib/python2.7/site-packages/spyder/utils/site/sitecustomize.py", line 705, in runfile
    execfile(filename, namespace)

  File "/Users/AMAL/anaconda2/lib/python2.7/site-packages/spyder/utils/site/sitecustomize.py", line 94, in execfile
    builtins.execfile(filename, *where)

  File "/Users/AMAL/p1", line 14, in <module>
    from spacy.en import English

  File "/Users/AMAL/anaconda2/lib/python2.7/site-packages/spacy/__init__.py", line 4, in <module>
    from .cli.info import info as cli_info

  File "/Users/AMAL/anaconda2/lib/python2.7/site-packages/spacy/cli/__init__.py", line 1, in <module>
    from .download import download

  File "/Users/AMAL/anaconda2/lib/python2.7/site-packages/spacy/cli/download.py", line 10, in <module>
    from .link import link

  File "/Users/AMAL/anaconda2/lib/python2.7/site-packages/spacy/cli/link.py", line 7, in <module>
    from ..compat import symlink_to, path2str

  File "/Users/AMAL/anaconda2/lib/python2.7/site-packages/spacy/compat.py", line 11, in <module>
    from thinc.neural.util import copy_array

  File "/Users/AMAL/anaconda2/lib/python2.7/site-packages/thinc/neural/__init__.py", line 1, in <module>
    from ._classes.model import Model

  File "/Users/AMAL/anaconda2/lib/python2.7/site-packages/thinc/neural/_classes/model.py", line 11, in <module>
    from .. import util

ImportError: cannot import name util

How can I fix this problem? what could be the problem? I'm super interested in including spaCy in my work, so any help will be truly appreciated.
Thank you,

A: (Spyder maintainer here) This problem seems related to an already reported bug in Spyder, which was fixed in our 3.2.8 version (released in March/2018).


text:
Q: Create a dropdownlist using JavaScript and add to div I'm struggling to get my javascript to work, what I'm trying to do, is create a dropdownlist with javascript and then populate it with values before adding it to a div.
I managed to get the code to work when it was just the for loop, but since I tried to create the list and add it to the div it no longer works.
var numberOfAdults = ["Adults (18+) ", "1", "2", "3", "4", "5", "6", "7", "8"];
                alert($(this).val());
                var numberOfRooms = $(this).val();
                switch (numberOfRooms) {
                    case "1":
                        //$('#AdultsRoom1').show();
                       // var list = document.createElement('select');
                       // list.setAttribute("id", "HotelRoom2");
                       // var adult = document.getElementById('HotelRoom2');
                        for (var i = 0; i < numberOfAdults.length; i++) {
                           var list = document.createElement('select');
                           list.setAttribute("id", "HotelRoom2");
                            var opt = document.createElement('option');
                            opt.innerHTML = numberOfAdults[i];
                            opt.value = numberOfAdults[i];
                            list.appendChild(opt);
                            $('#HotelRoom3').html(list);
                        }
                        break;
                }

Thanks for any help

A: I came up with this fiddle from the code you provided. It seems to be working now.
window.onload = function () {
    var numberOfAdults = ["Adults (18+) ", "1", "2", "3", "4", "5", "6", "7", "8"];
    //alert($(this).val());
    var numberOfRooms = "1";
    switch (numberOfRooms) {
        case "1":
            var list = document.createElement('select');
            list.setAttribute("id", "HotelRoom2");
            for (var i = 0; i < numberOfAdults.length; i++) {
                var opt = document.createElement('option');
                opt.innerHTML = numberOfAdults[i];
                opt.value = numberOfAdults[i];
                list.appendChild(opt);
            }
            $('#HotelRoom3').html(list);
            break;
    }
}


text:
Q: Why is this JavaScript not interpreted as a code block when semi-colon is used? In Chrome version ^72 if I run the following JavaScript there are no errors.
{ prop: p } = { prop: 'prop' }
>> { prop: 'prop' }

So the line of code is interpreted as an expression statement, unexpectedly.
But if I run the same code with a semi-colon at the end it runs as expected.
{ prop: p } = { prop: 'prop' };
>> Uncaught SyntaxError: Unexpected token =

This is expected since the initial { tells the JavaScript engine that it is a code block unless we disambiguate with parentheses.
Why does this occur with the semi-colon but not without it?

A:
Why does this occur with the semi-colon but not without it?

Chrome uses a very simple test to see whether a line is an object literal or not: Does the line start with a { and end with a }? If yes, the line is evaluated as an expression.
{ prop: p } = { prop: 'prop' } passes that test, but { prop: p } = { prop: 'prop' }; does not.

See Odd behaviour of comparison of object literals for more info (different input, same reason).


text:
Q: Deriving expression for general cubic equation solution. This is for the page #1,page #2, page #3, page #4 of the book by Dickson, titled "Introduction to Theory of Algebraic Equations", in which there is derivation of solution for general cubic equation.
 My question is about not being able to get the desired equality (named $D$, later below) stated at the bottom of page #3.
I request geometrical significance of different root pairs $y_1, y_2, y_3$, so as to understand the way to pursue further.
At the bottom of page $3$ it is given that ( Taking as first equality ($A$)  ):$$\sqrt[3]{\frac{-1}{2}q+\sqrt{R}}= \frac{1}{3}(y_1+\omega (\omega y_2+y_3))$$
$$\frac{-1}{2}q+\sqrt{R}= \frac{1}{27}(y_1+\omega (\omega y_2+y_3))^3
 = \frac{1}{27}(y_1^3 +(\omega\cdot y_2+y_3)^3 + 3\omega y_1^2(\omega\cdot y_2+y_3) + 3\omega^2\cdot y_1(\omega\cdot y_2+y_3)^2)$$
$$=\frac{1}{27}(y_1^3 +(\omega^3\cdot y_2^3 +y_3^3 +3\omega^2\cdot y_2^2y_3+3\omega\cdot y_2y_3^2)+3\omega^2 y_1^2y_2+3\omega y_1^2y_3+3\omega^2 y_1(\omega^2\cdot y_2^2+y_3^2+2\omega\cdot y_2y_3))$$
$$=\frac{1}{27}(y_1^3 +y_2^3 +y_3^3+6y_1y_2y_3+3\omega^2\cdot y_2^2y_3+3\omega\cdot y_2y_3^2+3\omega^2 y_1^2y_2+ 3\omega y_1^2y_3 + 3\omega y_1y_2^2+3\omega^2 y_1y_3^2) $$

At the bottom of page $3$ it is next given that ( Taking as second equality ($B$)  ): $$\sqrt[3]{\frac{-1}{2}q-\sqrt{R}}= \frac{1}{3}(y_1+\omega(\omega y_3+y_2))$$
$$\frac{-1}{2}q-\sqrt{R}= \frac{1}{27}(y_1+\omega(\omega y_3+y_2))^3
 = \frac{1}{27}(y_1^3 +(\omega\cdot y_3+y_2)^3 + 3\omega y_1^2(\omega\cdot y_3+y_2) + 3\omega^2\cdot y_1(\omega\cdot y_3+y_2)^2)$$
$$=\frac{1}{27}(y_1^3 +(\omega^3\cdot y_3^3 +y_2^3 +3\omega^2\cdot y_3^2y_2+3\omega\cdot y_3y_2^2)+3\omega^2y_1^2y_3+3\omega y_1^2y_2+3\omega^2 y_1(\omega^2\cdot y_3^2+y_2^2+2\omega\cdot y_3y_2))$$
$$=\frac{1}{27}(y_1^3 +y_3^3 +y_2^3+6y_1y_2y_3+3w^2\cdot y_3^2y_2+3\omega\cdot y_3y_2^2+3\omega^2 y_1^2y_3+ 3\omega y_1^2y_2 + 3\omega y_1y_3^2+3\omega^2 y_1y_2^2)$$

At the bottom of page $3$, further the difference of the above equalities is taken up ( Taking the difference as third equality ($C$)  ):
$$2\sqrt{R}=\frac{1}{27}((3\omega^2\cdot y_2^2y_3+3\omega\cdot y_2y_3^2+3\omega^2 y_1^2y_2+ 3\omega y_1^2y_3 + 3\omega y_1y_2^2+3\omega^2 y_1y_3^2) -(3\omega^2\cdot y_3^2y_2+3\omega\cdot y_3y_2^2+3\omega^2 y_1^2y_3+ 3\omega y_1^2y_2 + 3\omega y_1y_3^2+3\omega^2 y_1y_2^2))$$
$$\sqrt{R}=\frac{1}{54}(3\omega^2\cdot y_2y_3(y_2-y_3)+3\omega\cdot y_2y_3(y_3-y_2)+3\omega^2 y_1y_2(y_1-y_2)+ 3\omega y_1y_3(y_1-y_3) + 3\omega y_1y_2(y_2-y_1)+3\omega^2 y_1y_3(y_3-y_1))$$
$$=\frac{1}{54}(3\omega(\omega -1)y_1y_2(y_1-y_2)+3\omega (\omega -1)y_2y_3(y_2-y_3)+3\omega(\omega -1)y_1y_3(y_3-y_1))$$
$$=\frac{1}{54}(3(\omega^2-\omega)(y_1y_2(y_1-y_2)+y_2y_3(y_2-y_3)+y_1y_3(y_3-y_1)))$$
$$=\frac{(\omega^2-\omega)}{18}(y_1y_2(y_1-y_2)+y_2y_3(y_2-y_3)+y_1y_3(y_3-y_1))$$
$$=\frac{\sqrt{-3}}{18}(y_1y_2(y_1-y_2)+y_2y_3(y_2-y_3)+y_1y_3(y_3-y_1))$$
How to show the last equality ($C$) equal to the given one below one (let equality $D$) is not apparent to me
$$\sqrt{R}= \frac{\sqrt{-3}}{18}(y_1-y_2)(y_2-y_3)(y_3-y_1)$$
All I could attempt is to take the values of $y_1, y_2,y_3$ and find the products : $y_1y_2, y_2y_3, y_3y_1$.
$$y_1= \sqrt[3]{-\frac{q}{2}+\sqrt{R}} + \sqrt[3]{-\frac{q}{2}-\sqrt{R}}$$
$$y_2= \omega \sqrt[3]{-\frac{q}{2}+\sqrt{R}} + \omega^2\sqrt[3]{-\frac{q}{2}-\sqrt{R}}$$
$$y_3= \omega^2 \sqrt[3]{-\frac{q}{2}+\sqrt{R}} + \omega\sqrt[3]{-\frac{q}{2}-\sqrt{R}}$$

$$y_1y_2= (\sqrt[3]{-\frac{q}{2}+\sqrt{R}} + \sqrt[3]{-\frac{q}{2}-\sqrt{R}}\,\,\,)\cdot (\omega \sqrt[3]{-\frac{q}{2}+\sqrt{R}} + \omega^2\sqrt[3]{-\frac{q}{2}-\sqrt{R}}\,\,\,)$$
$$=\omega \,\,\sqrt[2/3]{-\frac{q}{2}+\sqrt{R}}+\omega^2 \sqrt[2/3]{-\frac{q}{2}-\sqrt{R}}+(\omega+\omega^2)(\sqrt[3]{-\frac{q}{2}+\sqrt{R}}\,\,\,\sqrt[3]{-\frac{q}{2}-\sqrt{R}}\,\,\,)$$

$$y_1y_3= (\sqrt[3]{-\frac{q}{2}+\sqrt{R}} + \sqrt[3]{-\frac{q}{2}-\sqrt{R}}\,\,\,)\cdot (\omega^2 \sqrt[3]{-\frac{q}{2}+\sqrt{R}} + \omega\,\,\sqrt[3]{-\frac{q}{2}-\sqrt{R}}\,\,\,)$$
$$=\omega^2 \sqrt[2/3]{-\frac{q}{2}+\sqrt{R}}+\omega\,\, \sqrt[2/3]{-\frac{q}{2}-\sqrt{R}}+(\omega+\omega^2)(\sqrt[3]{-\frac{q}{2}+\sqrt{R}}\,\,\,\sqrt[3]{-\frac{q}{2}-\sqrt{R}}\,\,\,)$$

$$y_3y_2= (\omega^2 \sqrt[3]{-\frac{q}{2}+\sqrt{R}} + \omega\,\,\sqrt[3]{-\frac{q}{2}-\sqrt{R}}\,\,\,)\cdot (\omega \sqrt[3]{-\frac{q}{2}+\sqrt{R}} + \omega^2\sqrt[3]{-\frac{q}{2}-\sqrt{R}}\,\,\,)$$
$$=\sqrt[2/3]{-\frac{q}{2}+\sqrt{R}}+\sqrt[2/3]{-\frac{q}{2}-\sqrt{R}}+(\omega+\omega^2)(\sqrt[3]{-\frac{q}{2}+\sqrt{R}}\,\,\,\sqrt[3]{-\frac{q}{2}-\sqrt{R}}\,\,\,)$$
$$=\omega^3 \sqrt[2/3]{-\frac{q}{2}+\sqrt{R}}+ \omega^3 \sqrt[2/3]{-\frac{q}{2}-\sqrt{R}}+(\omega+\omega^2)(\sqrt[3]{-\frac{q}{2}+\sqrt{R}}\,\,\,\sqrt[3]{-\frac{q}{2}-\sqrt{R}}\,\,\,)$$

A: Both $y$ expressions expand to $y_1y_2^2-y_1y_3^2-y_2y_1^2+y_2y_3^2+y_3y_1^2-y_3y_2^2$, and $\omega^2-\omega=2i\Im(\omega)=i\sqrt3$.

A: There isn't a sign mistake in the book. Note that $\omega - \omega^2 = \sqrt{-3}$.
$$\frac{(\omega^2-\omega)}{18}(y_1y_2(y_1-y_2)+y_2y_3(y_2-y_3)+y_1y_3(y_3-y_1))$$
$$=\frac{\color{red}{-}\sqrt{-3}}{18}(y_1y_2(y_1-y_2)+y_2y_3(y_2-y_3)+y_1y_3(y_3-y_1))$$
Alternative:
\begin{align}
&\frac1{54}((y_1+\omega^2y_2+\omega y_3)^3 - (y_1+\omega y_2+\omega^2 y_3)^3)\\
&=\frac1{54}(\omega^2y_2-\omega y_2+\omega y_3 - \omega^2 y_3)((y_1+\omega^2y_2 + \omega y_3)^2+(y_1+\omega^2y_2 + \omega y_3)(y_1+\omega y_2 + \omega^2 y_3)+(y_1+\omega y_2 + \omega^2 y_3)^2)\\
&=\frac{-(\omega - \omega^2)}{54}(y_2-y_3)(3y_1^2+[2(\omega^2y_2 + \omega y_3)+2(\omega y_2 + \omega^2 y_3)+(\omega^2+\omega)(y_2+y_3)]y_1+(\omega^2y_2 + \omega y_3)^2+(\omega^2y_2 + \omega y_3)(\omega y_2 + \omega^2 y_3)+(\omega y_2 + \omega^2 y_3)^2)\\
&= \frac{-\sqrt{-3}}{54}(y_2-y_3)(3y_1^2-3(y_2+y_3)y_1+(\omega y_2^2 + \omega^2 y_3^2+2y_2y_3)+y_2^2+y_3^2+(\omega+\omega^2)y_2y_3+(\omega^2 y_2^2 + \omega y_3^2+2y_2y_3))\\
&=\frac{-\sqrt{-3}}{54}(y_2-y_3)(3y_1^2-3(y_2+y_3)y_1+3y_2y_3)\\
&=\frac{-\sqrt{-3}}{18}(y_2-y_3)(y_1-y_2)(y_1-y_3)\\
&=\frac{\sqrt{-3}}{18}(y_1-y_2)(y_2-y_3)(y_3-y_1)\\
\end{align}


text:
Q: LinkedIn's new share button still has old appearance LinkedIn claims to have updated their share button to a new appearance with a flatter style similar to facebook's. However, despite using their publisher code generator the appearance has not updated on my site.
<script type="text/javascript" src="http://platform.linkedin.com/in.js">
</script><script type="in/share" data-url="https://myurlhere.com" data-counter="right" data-showzero="right" ></script>

Anyone has any idea what I am missing?

A: The appearance of the share buttons will updates automatically after a few days.
There is nothing extra that the site administrators need to do other than follow the developer instructions at https://developer.linkedin.com/plugins/share


text:
Q: Azure Functions with trigger timer don't show logs under Monitor I'm testing my Azure Functions and facing a funny problem. I want to see if a function was running and the result. I'm opening the function and then my function called getTokenRefresh. Apparently, this function has never started.

After a couple of hours, I decided to open Application Insights. Surprise! All logs are there.

If I run a function from the portal and open again monitor and click on the Logs tab, I don't see any logs. Again I can find everything only in Application Insights.
Another interesting thing is other functions in this Azure Functions, show me all details (believe me is the same function).

In the code point of view, I'm using dependency injection in all functions like:
public class GetTokenRefreshTimer
{
    private ILogger _log;

    public GetTokenRefreshTimer(ILogger<GetTokenRefreshTimer> log)
    {
        _log = log;
    }

    [FunctionName("getTokenRefreshTimer")]
    public async Task Run([TimerTrigger("0 */20 * * * *")]TimerInfo myTimer)
    {
        _log.LogInformation("GetTokenRefresh starts");
    }
}

A: The logs of azure function is fragile. So sometimes you can not see the logs, but this doesn't mean the azure function is not run.
If you want to know the function is running you need to go to the kudu of your azure function and see the logs file of your function app.(The logs in Application Insights is coming from this place.)
The logs file is in the place:
Open your brower and go to https://yourfunctionappname.scm.azurewebsites.net/DebugConsole, and then click into LogFiles/Application/Functions/Function/yourtriggername . You will find the log file in this place.


text:
Q: Why does code below fs.readFile callback function run before the callback? fs.readFile('input.txt', function(err, data) {
  if (err) {
    return console.error(err);
  }
  console.log(data.toString());
});

console.log("Program Ended");

input.txt contains the string "hello".
The above code prints:
Program Ended
hello

Why does it print "program ended" before "hello"?
Is it not line by line execution?

A: Code inside your callback function (the one which prints the file content) does not block execution. It is executed asynchronously after the file is read.

A: fs.readFile is asynchronous, meaning that, as @madox2 said, it will not block execution. If you want to log Program Ended after fs.readFile, you can use fs.readFileSync. fs.readFileSync is synchronous, meaning that console.log("Program Ended") will be executed after.


text:
Q: Using Bootstrap grid with fixed position div I am trying to use the Bootstrap grid layout, but also with one div that is fixed vertically as you scroll down the page. To fix the div, I am using 'position:fixed' but this seems to break the containing class. The text overflows into the next column, which it shouldn't do.

                Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque blandit euismod dolor id posuere. In vulputate lacinia sem vel dignissim. Donec eu ornare lacus. Vestibulum quis enim et mauris mattis commodo blandit eget lectus. Sed sem augue, aliquet ac vulputate in, congue suscipit justo. Duis ac rhoncus tellus. Sed eu faucibus leo. Mauris imperdiet nisi vitae nisi varius, a egestas purus laoreet. Suspendisse eu sodales mi. Nunc in laoreet ipsum, id mattis massa. Sed in iaculis augue, vel commodo turpis. Aliquam placerat velit in justo vulputate, eu pulvinar nunc facilisis. Maecenas sit amet purus est. Integer in pharetra tortor. Donec ac lorem massa. Fusce ac eros pharetra, blandit tellus at, varius velit.

                Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque blandit euismod dolor id posuere.

                This should remain fixed as I scroll down the page

                Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque blandit euismod dolor id posuere.

What should I do to keep the div fixed as I scroll, but also adhere to the grid layout that Bootstrap sets out?

A: What I did to solve this was to make jQuery get the size of the div at the page load, then pass it to the internal div's css.  like this:
var divWidth = $( '.yourDiv' ).width();

This will grab the width as soon as the page loads.
function keepDivWidth() {
  $( window ).scroll( function () {
    var top = $( window ).scrollTop();
    if ( top >= 10 ) ) {
      $( '.yourDiv' ).addClass( 'fixed' );
      $( '.yourDiv' ).css({
         "width" : divWidth
         })
    }else{
      $( '.yourDiv' ).removeClass( 'fixed' );
      $( '.yourDiv' ).css({
        "width" : ""
      })
    }
  })
}(jQuery);

the  if ( top >= 10 )  part can be anything you want. The '10' is just filler
Then it is as easy as calling your new function in your web page!
$(document).ready(function(){
    keepDivWidth();
});

Or, I think you can just wrap what you need in a div with class of row. I haven't tested that yet though.


text:
Q: PostgreSQL: 42883 Operator does not exist: timestamp without time zone = text I am using Npgsql 3.0.3.0 and PetaPoco latest version.
When I run this command:
var dateCreated = DateTime.Now; // just an example
var sql = new Sql("WHERE date_created = @0", dateCreated.ToString("yyyy-MM-dd HH:00:00"));
var category = db.SingleOrDefault<Category>(sql);

I get the following error:

Npgsql.NpgsqlException 42883: operator does not exist: timestamp
  without time zone = text

I understand the error message is saying I'm trying to compare a timestamp (date) with a text, however for me it's perfectly valid to compare them as I am expecting the following SQL statement to be built:
SELECT * FROM category WHERE date_created = '2017-02-03 15:00:00'

I don't really want to typecast my database column to text for performance reasons.

A: You need to explicit typecast text to timestamp.
Try using :
TO_TIMESTAMP(date_string,'YYYY-MM-DD')

A: You need to cast value to timestsamp:
var sql = new Sql("WHERE date_created = @0::timestamp", dateCreated.ToString("yyyy-MM-dd HH:00:00"));

A: As @roman-tkachuk answered, you can tell PostgreSQL to cast your string into a timestamp.
Or better yet, you can simply send a timestamp to PostgreSQL directly, rather than sending a string representation of a timestamp and having it cast. To do that, simply send dateCreated directly, without the ToString().


text:
Q: Oracle Apex 22.21 - How to refresh multiple regions with one dynamic action I have two charts on one page. There are also two datepicker items (Date From and Date To) so the user can choose between two dates and get a range of values.

I understand how to implement the datepicker for one chart and it works for me as expected. But how can I have the datepicker refresh the both charts at the same time?
I've found another SO question and followed Daniel's answer to give each region a static id.
So I've added the static id of region1 to the first chart and region2 to the second chart.

Then, I changed the datepicker dynamic action selection type to Javascript Expression and added the following
apex.region('#region1').refresh();
apex.region('#region2').refresh();

But the refresh doesn't fire when I choose a new date.
Daniel's answer in the other question did mention a JS API. Is this something I link up with Apex or is it already included out the box?

A:
How to refresh multiple regions with one dynamic action

I presume/hope that this should do:


text:
Q: Convert .voc audio to wav in node.js How to convert voc audio file to wav in node.js?
I want to convert voc audio file to wav or mp3
But I didn't found any module for that.
Is there node module for this? I have searched for many hours and didn't found any helpful module to do this
Anyone please help


text:
Q: 'Font' is not convertible to 'Font?' in SwiftUI Tutorial In Apple SwiftUI Tutorial, I just encountered some error.
https://developer.apple.com/tutorials/swiftui/building-lists-and-navigation
In this tutorial, after step 8, 9, 10, the error occurs.
This is what I wrote:
import SwiftUI

struct LandmarkDetail : View {

var landmark: Landmark

var body: some View {
    VStack {

        MapView(landmark.locationCoordinate)
            .edgesIgnoringSafeArea(.top)
            .frame(height: 300)

        CircleImage(landmark.image(forSize: 50)).offset(y: -130)
        .padding(.bottom, -130)

        VStack(alignment: .leading){
            Text(landmark.name)
                .font(.title)

            HStack{
                Text(landmark.park)
                    .font(.subheadline)
                Spacer()
                Text(landmark.state)
                    .font(.subheadline)
            }
        }
        .padding(30)

        Spacer()
        }
}

This code runs well without any error.
But after changed some constants to a variable, these error occurs.
I had tried to restart Xcode for several times, but it doesn't work.
What's wrong with it?
Below is what Apple wrote:
var body: some View {
    VStack {
        MapView(coordinate: landmark.locationCoordinate)
            .frame(height: 300)

        CircleImage(image: landmark.image(forSize: 250))
            .offset(y: -130)
            .padding(.bottom, -130)

        VStack(alignment: .leading) {
            Text(landmark.name)
                .font(.title)

            HStack(alignment: .top) {
                Text(landmark.park)
                    .font(.subheadline)
                Spacer()
                Text(landmark.state)
                    .font(.subheadline)
            }
        }
        .padding()

        Spacer()
    }

Xcode : Version 11.0 beta (11M336w)

A: Change These two lines,
        MapView(landmark.locationCoordinate)
            .edgesIgnoringSafeArea(.top)
            .frame(height: 300)

        CircleImage(landmark.image(forSize: 50)).offset(y: -130)
        .padding(.bottom, -130)

to this,
        MapView(coordinate: landmark.locationCoordinate)
                .edgesIgnoringSafeArea(.top)
                .frame(height: 300)

        CircleImage(image: landmark.image(forSize: 50)).offset(y: -130)
                .padding(.bottom, -130)


text:
Q: How to handle large amount of data in browsers local storage on Angular 4? I have developing one web app in Angular 4. That has returning the 50k+ records from API. With that I need to store that data in to local storage and handle offline once data return. I tried with localstoarge but localstoarge not storing all data. Because it have maximum limit 5MB and it will change based on browser. Suggestion any idea?
Thanks,

A: Use IndexedDB instead - it has a much greater size limit, and is perfectly suited for organizing large amounts of structured data. It's significantly more tricky to use than localStorage, but it's your only other option if you want to store data too large for localStorage.


text:
Q: Why add -webkit- prefix in CSS when things still work without it? background: linear-gradient(#0081D3, #E44211); just works fine in most modern browsers.
Why are -webkit-linear-gradient, -moz-linear-gradient etc. used sometimes?

A:
Vendor prefixes such as -webkit- or -moz- are used to add new
  features that may not be part of a formal specification, to add
  support for new CSS features in a sort of testing and experimentation
  period.
  - reference

Web browser makers uses these prefixes for CSS experimental features, hence the old browsers may support new CSS features under the vendor prefix.
While the syntax of a CSS feature (e.g. gradient) could be different between the vendor implementation and the formal specification:
/* Old syntax for Safari 4+, Chrome 1-9 */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#1e5799), color-stop(100%,#7db9e8));

/* W3C Spec */
background: linear-gradient(to bottom, #1e5799 0%,#7db9e8 100%);

Check the MDN or WebPlatform doc for further information.

A: They are called "Vendor Prefixes" and you need them for compatibility with older browseres. CSS3 is a changing standard, so some functions are not implemented without these prefixes when the developers are still working on them.
You have to think about the older browsers because they are still used by many people.
See this for more information: http://css-tricks.com/how-to-deal-with-vendor-prefixes/


text:
Q: 2-pairings in a set A, where |A|=8 The task is to assign 8 tennis players into pairs of 2 for a bracket.
The answer is 105, for which my textbook used the method:
1. Select the 4 pairs, for which there are 8C2*6C2*4C2*2C2 ways.
2. Divide by the number of permutations for the pairs, which is 4P4.
(8C2*6C2*4C2*2C2)/4P4 = 105 pairings.
I'm wondering what I'm doing wrong with this other method that I tried:
1. Select all combinations of 4 players for the left side of the bracket, 8C4.
2. For each such combination, pair it with all permutations of the other 4 players, 4P4.
3. This should overestimate by a factor of 2 (mirror images), because the left-side {a,b,c,d} will duplicate with the left-side {e,f,g,h}.
However, (8C4*4P4)/2 = 840, which is still off by a factor of 8. What duplicates have a neglected to remove?


text:
Q: SQL Server 2005 Message Localisation I have a bunch of stored procedures which use RAISERROR to return to the client C# application certain business-logic error messages, and now I wonder if there is a way to localize these message in a way similar to .NET. Can these messages be localized somehow, or do they have to be hard-coded in the "main" language being used?
Side question: I have a .NET class library containing a resource file with strings. Can I use this dll from SQL Server 2005 and retrieve these error messages from that resource file?

A: SQL Server has localisation for the built-in system messages for many languages/locales.
For your own custom messages, you will have to catch and translate them in your application layer.
It 'might' be possible to use your .NET dll from SQL Server 2005 and retrieve these error messages from that resource file using a CLR Stored Procedure, but I wouldn't recommended doing it that way (it has permissions/deployment implications that are frankly best avoided).

A: Mitch indicated that the built in messages are localized. He didn't mention that you can use the same localization system for your own message. sp_addmessage lets you add new messages (and specify the language).
You then use the version of RAISERROR that uses a message number, rather than a message text.


text:
Q: Why won't boto3's FilterExpression accept more than 1 expression? I am really baffled as to what I am doing wrong. It seems like the request I am making to the boto3 dynamodb client is perfect from what I can tell, but I am still not getting any results when I run the query. I suspect it's something to do with the FilterExpression, but I can't fathom it.
I am using a zappa/flask combo to build a web app, and I'm using dynamodb as the database. My AWS credentials and permissions are fine--I know that because I can run simpler queries just fine. Beyond that, the wider context of the application isn't relevant to my question.
I am running the following commands within the context of an object:
args = {... see below ...}
self.db = boto3.client('dynamodb')
self.db.query(**args)

Below is the args argument that I send to the client:
{"TableName": "clients",
"IndexName": "client_id",
"FilterExpression": "#filattr0 < :filattrval0 AND #filattr1 = :filattrval1",
"KeyConditionExpression": "#keyindexattr0 = :keyindexvalue0",
"ExpressionAttributeNames": {
    "#filattr0": "time",
    "#filattr1": "status",
    "#keyindexattr0": "client_id"
},
"ExpressionAttributeValues": {
    ":filattrval0": {"N": "1542696080"},
    ":filattrval1": {"S": "pending"},
    ":keyindexvalue0": {"S": "00000000-0000-0000-000000000000"}
},
"Limit": 100,
"ConsistentRead": false,
"Select": "ALL_ATTRIBUTES"}

The response I get back from this query is the following:
{'Items': [],
'Count': 0,
'ScannedCount': 8,
'ResponseMetadata': {'RequestId': '*blahblahblah*',
'HTTPStatusCode': 200,
'HTTPHeaders': {
    'server': 'Server',
    'date': 'Tue, 20 Nov 2018 06:41:20 GMT',
    'content-type': 'application/x-amz-json-1.0',
    'content-length': '39',
    'connection': 'keep-alive',
    'x-amzn-requestid': '*blahblahblah*',
    'x-amz-crc32': '*numbers*'},
    'RetryAttempts': 0
}}

Now, I am looking at the dynamodb table through my AWS Console, and it is showing me the following object in the appropriate table. In fact, when I construct this query in the table view of the dynamodb console on the AWS Website, it returns the following object, so I know the parameters are acceptable to AWS:
# Taken from the JSON view of the item in the database
# I removed the UUIDs just in case...
{
    "client_id": "00000000-0000-0000-000000000000",
    "modify_date": "1542637150",
    "schedule_id": "00000000-0000-0000-000000000000",
    "software_version": "0.1",
    "status": "pending",
    "template_id": "00000000-0000-0000-000000000000",
    "time": "1542646800",
    "timezone": "PDT"
}

The weirdest thing is that when I run the query using the following args variable:
{'TableName': 'hmcmSchedule',
'IndexName': 'client_id',
'FilterExpression': '#filattr0 = :filattrval0',
'KeyConditionExpression': '#keyindexattr0 = :keyindexvalue0',
'ExpressionAttributeNames': {
    '#filattr0': 'status',
    '#keyindexattr0': 'client_id'
},
'ExpressionAttributeValues': {
    ':filattrval0': {'S': 'pending'},
    ':keyindexvalue0': {'S': '00000000-0000-0000-000000000000'}
},
'Limit': 100,
'ConsistentRead': False,
'Select': 'ALL_ATTRIBUTES'}

I get the following response from the database:
# UUIDs have once again been removed, just in case...
{'Items': [{
    'modify_date': {'S': '1542637150'},
    'template_id': {'S': '00000000-0000-0000-000000000000'},
    'software_version': {'S': '0.1'},
    'client_id': {'S': '00000000-0000-0000-000000000000'},
    'status': {'S': 'pending'},
    'timezone': {'S': 'PDT'},
    'time': {'S': '1542646800'},
    'schedule_id': {'S': '00000000-0000-0000-000000000000'}
}],
'Count': 1,
'ScannedCount': 8,
'ResponseMetadata': {
    'RequestId': '*blahblahblah*',
    'HTTPStatusCode': 200,
    'HTTPHeaders': {
        'server': 'Server',
        'date': 'Tue, 20 Nov 2018 07:55:59 GMT',
        'content-type': 'application/x-amz-json-1.0',
        'content-length': '348',
        'connection': 'keep-alive',
        'x-amzn-requestid': '*blahblahblah*',
        'x-amz-crc32': '1922642857'
    },
    'RetryAttempts': 0}}

What is it about my FilterExpression that is keeping this from working? I've been examining it for hours, and can't see the forest for the trees. I read the documentation extensively, and I think i've covered everything.
Any help or insight anybody could offer would b greatly appreciated...

A: No, @Michael-sqlbot was right. The issue turned out to be a combination of problems that I just didn't pick up on. I had everything correct but the portion where I was specifying the ExpressionAttributeValues:
So this:
"ExpressionAttributeValues": {
    ":filattrval0": {"N": "1542696080"},
    ":filattrval1": {"S": "pending"},
    ":keyindexvalue0": {"S": "00000000-0000-0000-000000000000"}
},

Was entirely correct. The problems I kept having were that I would switch databases without switching attributes, the parameters I set didn't match anything in the database, or--as @Michael-sqlbot pointed out--the value of time stored in the database was of a different datatype.
You can't compare a number against a string, as it turns out. And since I was debugging from Zappa tail --since 5m, I often wound up looking at the wrong material.
So I was right, the code does work, i'm not insane, and I shouldn't code when i'm really tired.


text:
Q: mvn deploy json-lib to neuxs is wrong Company server can not even outside the network, now need to json-lib jar package to nexus

mvn deploy:deploy-file -Durl=http://ip:port/repository/maven-releases -DrepositoryId=nexus -DgeneratePom=false -DpomFile=json-lib-2.4.pom -Dpackaging=jar  -Dfile=json-lib-2.4-jdk15.jar -DgroupId=net.sf.json-lib -DartifactId=json-lib

json-lib

But spread to nexus, found jar package file name is wrong, as shown below
uploading.

nexus

How can I operate the jar correctly?

A: I suggest to check the version inside the json-lib-2.4.pom or add a "-Dversion=2.4-jdk15"


text:
Q: How to search text in OneNote file with Powershell I am trying to open a OneNote file (could be a file on a network share, not necessarily my own OneNote file) using Powershell.
I get an error

Exception calling "OpenHierarchy" with "4" argument(s): "Exception
  from HRESULT: 0x80042018"

on the call to OpenHierarchy and I could not find how to work around this.
Can anyone help? Here is my code:
$OneNote = New-Object -ComObject OneNote.Application

$OneNoteFilePath = "someNetworkPath"
[ref]$xml = ""
[xml]$Hierarchy = ""
$OneNote.OpenHierarchy($OneNoteFilePath, "", $xml, "cftNotebook")
$OneNote.GetHierarchy("", [Microsoft.Office.InterOp.OneNote.HierarchyScope]::hsPages, [ref]$Hierarchy)

ForEach($notebook in $Hierarchy.Notebooks.Notebook)
{
    [ref]$PageXML = ''
    $OneNote.GetPageContent($notebook.ID, [ref]$PageXML, [Microsoft.Office.Interop.OneNote.PageInfo]::piAll)

    If ($PageXML | Where-Object { $_ -match "\b$word\b" })
    {
        ## Do something
    }

    ForEach($section in $notebook.Section)
    {
        [ref]$PageXML = ''
        $OneNote.GetPageContent($notebook.ID, [ref]$PageXML, [Microsoft.Office.Interop.OneNote.PageInfo]::piAll)

        If ($PageXML | Where-Object { $_ -match "\b$word\b" })
        {
            ## Do something
        }
    }
}

A: There's a problem with the line:
$OneNote.OpenHierarchy($OneNoteFilePath, "", $xml, "cftNotebook")
The last parameter is supposed to be an int, 3, not a string "cftNotebook".
Or you can use the correct enumeration instead of 3: [Microsoft.Office.Interop.OneNote.CreateFileType]::cftSection
https://learn.microsoft.com/en-us/office/client-developer/onenote/application-interface-onenote
https://learn.microsoft.com/en-us/office/client-developer/onenote/enumerations-onenote-developer-reference#odc_CreateFileType
If you are looking for a working snippet, here's something to get you started:
$OneNote = New-Object -ComObject OneNote.Application

$OneNoteFilePath = "c:\path\to\onenote.one"
[ref]$oneNoteID = ""
[xml]$Hierarchy = ""
$OneNote.OpenHierarchy($OneNoteFilePath, "", $oneNoteID, [Microsoft.Office.Interop.OneNote.CreateFileType]::cftSection)
$OneNote.GetHierarchy($oneNoteID.Value, [Microsoft.Office.InterOp.OneNote.HierarchyScope]::hsPages, [ref]$Hierarchy)

#At this point, check $Heirarchy for what properties it has, it could be Notebooks, or SectionGroup, or Section

#If your $Hierarchy contains sections, you can do this
ForEach($page in $Hierarchy.Section.Page)
{
    [ref]$PageXML = ''
    $OneNote.GetPageContent($page.ID, [ref]$PageXML, [Microsoft.Office.Interop.OneNote.PageInfo]::piAll)
    Write-Output $PageXML.Value
}

Note that some sections can have section groups, in which case, you'll have to use some recursion.


text:
Q: Maven actionbarsherlock - Theme resources are not available I started using maven on ADT. I spent a day and most problems are resolved but I got stuck in a strange problem.
ActionBarSherlock is correctly integrated and I can use all classes provided by the library, but I cannot use the Themes of ABS on styles.xml and AndroidManifest.xml.
Dependency at pom.xml:
    <dependency>
        <groupId>com.actionbarsherlock</groupId>
        <artifactId>actionbarsherlock</artifactId>
        <version>4.4.0</version>
        <type>jar</type>
    </dependency>

Also tried:
    <dependency>
        <groupId>com.actionbarsherlock</groupId>
        <artifactId>actionbarsherlock</artifactId>
        <version>4.4.0</version>
        <type>apklib</type>
    </dependency>

The actionbarsherlock library is linked successfully so I can see actionbarsherlock-4.4.0.jar on Maven Dependencies on Java Build Path. I can access the classes from ABS, and can run mvn clean install and mvn android:run without any problem:
However, I cannot use the themes; for example:
android:theme="@style/Theme.Sherlock.NoActionBar"
...
<style name="AppBaseTheme" parent="Theme.Sherlock.Light.DarkActionBar">

Eclipse shows error messages like following:
error: Error: No resource found that matches the given name (at 'theme' with value '@style/Theme.Sherlock.NoActionBar').

I am using:

*

*android-maven-plugin 3.6.0

*maven 3.0.5 (I also tried maven 3.1.1)

*jdk 1.7

I tried a lot of approaches found on the web but couldn't resolve this problem. Could you help me..
Thank you in advance.

A: This line
<style name="AppBaseTheme" parent="Theme.Sherlock.Light.DarkActionBar">
should be
<style name="AppBaseTheme" parent="@style/Theme.Sherlock.Light.DarkActionBar">
(i.e.: with the "@style/" before the name of the parent theme).
Hope this helps


text:
Q: Convert haskell style type signature to C I have a set of haskell type signature, similar to below:
(for anyone that knows haskell, this is a monomorphised version of .. )
(t2 -> t3) -> (t1 -> t2) ->  t1 -> t3

And with the implicit parens (Conveniently, this is how my program currently stores the type signatures - as a tree.):
(t2 -> t3) -> ((t1 -> t2) -> (t1 -> t3))

I am looking for a programmatic way to convert this style of type signature to a C style type signature with function pointers. So far, all I have been able to find is resources concerning one, maybe two levels of function pointers - Obviously, in this case, I need it to support theoretically infinite levels. Any resources or pointers would be helpful.
Thank you in advance.
EDIT: Encoding the type as a C datastructure would also work.

A: If @Dmitry's comment accurately reflects what you're trying to do, the Haskell code to perform such a conversion is surprisingly simple:
data HType = (:->) HType HType | H String
  deriving (Show)
infixr 0 :->

ctype :: String -> HType -> String
ctype x (a :-> b) = ctype ("(*" ++ x ++ ")(" ++ ctype "" a ++ ")") b
ctype "" (H a) = a
ctype x  (H a) = a ++ " " ++ x

main = do
  let t = (H "t2" :-> H "t3") :-> (H "t1" :-> H "t2") :-> H "t1" :-> H "t3"
  putStrLn $ ctype "compose" t

For this example, it produces the type signature:
t3 (*(*(*compose)(t3 (*)(t2)))(t2 (*)(t1)))(t1)

which does, indeed, describe a type compose that's a pointer to a function that accepts a pointer to a function t2 -> t3, returning a pointer to a function that accepts a pointer to a function t1 -> t2 that returns a pointer to a function t1 -> t3.
It's a little hard to see how such a type could be used.  I mean, if you want to emit code for a compose function that could actually be assigned to such a pointer, it's tough to do without first-class functions.  As a proof of concept, here's a non-reentrant version using global variables that proves that the type "works":
#include <stdio.h>

/* some concrete types to use */
typedef char t1;
typedef int t2;
typedef char* t3;

/* compose :: (t2 -> t3) -> ((t1 -> t2) -> (t1 -> t3)) */
typedef t3 (*(*(*compose)(t3 (*)(t2)))(t2 (*)(t1)))(t1);

/* code defining a `do_compose` function pointer of C type `compose` */

t3 (*f1)(t2);
t2 (*f2)(t1);

t3 compose2(t1 x)
{
        return (*f1)((*f2)(x));
}

t3 (*compose1(t2 (*g)(t1)))(t1)
{
        f2 = g;
        return compose2;
}

t3 (*(*compose0(t3 (*f)(t2)))(t2 (*)(t1)))(t1)
{
        f1 = f;
        return compose1;
}

compose do_compose = compose0;

/*
 * a test case for `do_compose`
 */

/* ord :: t1 -> t2 */
int ord(char c)
{
        return (int)c;
}

/* print :: t2 -> t3 */
char* print(int i)
{
        static char buffer[256];
        sprintf(buffer, "%d", i);
        return buffer;
}

int main()
{
        puts(do_compose(print)(ord)('A'));
}

Alternatively, if you want an "uncurried" version of the type, which in this case would be:
t3 (*compose)(t3 (*)(t2), t2 (*)(t1), t1)

(i.e., compose is a pointer to a function that takes a pointer to a function t2 -> t3, a pointer to a function t1 -> t2, and a value of type t1 and then returns a value of type t3), the Haskell code still isn't too bad:
ctype' :: String -> HType -> String
ctype' "" (H a) = a
ctype' x (H a) = a ++ " " ++ x
ctype' x funcall = go [] funcall
  where go args (a :-> b) = go (ctype "" a : args) b
        go args b = ctype ("(*" ++ x ++ ")(" ++ intercalate ", " (reverse args) ++ ")") b

The resulting function is much more ergonomic for implementation in C:
/* compose :: (t2 -> t3) -> ((t1 -> t2) -> (t1 -> t3)), uncurried version */
typedef t3 (*compose)(t3 (*)(t2), t2 (*)(t1), t1);

t3 compose0(t3 (*f)(t2), t2 (*g)(t1), t1 x)
{
        return (*f)((*g)(x));
}

compose do_compose = compose0;

...

int main()
{
        puts(do_compose(print, ord, 'A'));
}

A: If you want a C data structure, this will do it (quick and dirty):
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

typedef struct type_s {
  enum { FUNCTION, VAR } kind;
  union {
    struct function_s {
      struct type_s *from;
      struct type_s *to;
    } function;
    int var_n;
  };
} TYPE;

TYPE *make_function(TYPE *from, TYPE *to) {
  TYPE *t = malloc(sizeof *t);
  t->kind = FUNCTION;
  t->function.from = from;
  t->function.to = to;
  return t;
}

TYPE *make_var(int n) {
  TYPE *t = malloc(sizeof *t);
  t->kind = VAR;
  t->var_n = n;
  return t;
}

void print(TYPE *t) {
  switch (t->kind) {
    case FUNCTION:
      printf("(");
      print(t->function.from);
      printf(" -> ");
      print(t->function.to);
      printf(")");
      break;
    case VAR:
      printf("t%d", t->var_n);
      break;
    default:
      printf("Bad type kind %d\n", t->kind);
      exit(1);
  }
}

typedef enum { LP, RP, ID, ARROW, END_INPUT } TOKEN;
static char *token_str[] = { "(", ")", "ID", "->", "<end>", };

static int scanned_id;
static int ch;

void get_next(void) {
  ch = getchar();
}

void require(int required) {
  if (ch != required) {
    fprintf(stderr, "Required %c, saw %c\n", required, ch);
  }
}

TOKEN scan(void) {
  while (isspace(ch)) get_next();
  switch (ch) {
    case '(':
      get_next();
      return LP;
    case ')':
      get_next();
      return RP;
    case '-':
      get_next();
      require('>');
      get_next();
      return ARROW;
    case 't':
      get_next();
      scanned_id = 0;
      while (isdigit(ch)) {
        scanned_id = scanned_id * 10 + (ch - '0');
        get_next();
      }
      return ID;
    case EOF:
      return END_INPUT;
    default:
      fprintf(stderr, "Bad char: %c (%d)\n", ch, ch);
      exit(1);
  }
}

/*
 * Grammar:
 * S -> expr $
 * expr -> term | term -> expr
 * term -> ID | LP expr RP
 */

TOKEN tok;

void advance(void) {
  tok = scan();
}

void match(TOKEN t) {
  if (tok != t) {
    fprintf(stderr, "Expected %s, found %s\n", token_str[t], token_str[tok]);
    exit(1);
  }
  advance();
}

TYPE *expr(void);
TYPE *term(void);

TYPE *parse(void) {
  TYPE *t = expr();
  match(END_INPUT);
  return t;
}

TYPE *expr(void) {
  TYPE *t = term();
  if (tok == ARROW) {
    advance();
    return make_function(t, expr());
  }
  return t;
}

TYPE *term(void) {
  if (tok == ID) {
    TYPE *t = make_var(scanned_id);
    advance();
    return t;
  }
  match(LP);
  TYPE *t = expr();
  match(RP);
  return t;
}

int main(void) {
  get_next();
  advance();
  TYPE *t = parse();
  print(t);
  printf("\n");
  return 0;
}


text:
Q: Add icon within input field using Core MVC and unobtrusive validation My code works fine for bordering the input box red or green based on valid/error state, however how would I get an exclamation icon (font awesome?) to display on the inside right of the field? I am Using Bootstrap 3.3.7.

How many?

            <input class="form-control" asp-for="Quantity" />


text:
Q: amavisd-new freezes: "Address already in use" I have a mail server setup running on my Debian Jessie VPS which includes postfix, amavisd-new, SpamAssassin and a few other services.
All in all it seems my setup works pretty well and handles incoming mails correctly, however from time to time amavisd-new freezes ('systemctl status amavis.service' shows 'active (exited)').
Based on the amavisd-new logs I suppose it is caused by SpamAssassin's update job, which from my understanding fails to shut down amavisd-new properly; still, I can't make any sense of it.
Amavisd-new is in version 1:2.10.1-2~deb8u1, SpamAssassin is in version 3.4.1-3~bpo8+1.
Does anybody have a suggestion how to correct this or where to dig deeper?
Here is what amavis logs (with verbosity level set to 5) right before the freeze:
Aug 27 06:58:00 server.example.com /usr/sbin/amavisd-new[2476]: Net::Server: 2016/08/27-06:57:57 Server closing!
Aug 27 06:58:01 server.example.com /usr/sbin/amavisd-new[2476]: Net::Server: Kill TERM pid 2496
Aug 27 06:58:01 server.example.com /usr/sbin/amavisd-new[2476]: Net::Server: Kill TERM pid 2495
Aug 27 06:58:05 server.example.com /usr/sbin/amavisd-new[2495]: child_goes_idle (child finishing)
Aug 27 06:58:08 server.example.com /usr/sbin/amavisd-new[2495]: child_goes_idle: disconnected none (child finishing)
Aug 27 06:58:06 server.example.com /usr/sbin/amavisd-new[2496]: (02496-01) child_goes_idle (child finishing)
Aug 27 06:58:10 server.example.com /usr/sbin/amavisd-new[2496]: (02496-01) child_goes_idle: disconnected none (child finishing)
Aug 27 06:58:10 server.example.com /usr/sbin/amavisd-new[2496]: (02496-01) SA rundown_child (0)
Aug 27 06:58:10 server.example.com /usr/sbin/amavisd-new[2495]: SA rundown_child (0)
Aug 27 06:58:13 server.example.com /usr/sbin/amavisd-new[13635]: logging initialized, log level 5, logfile: /var/log/amavis.log
Aug 27 06:58:13 server.example.com /usr/sbin/amavisd-new[13635]: starting. /usr/sbin/amavisd-new at server.example.com amavisd-new-2.10.1 (20141025), Unicode aware, LC_ALL="C", LANG="de_DE.UTF-8"
Aug 27 06:58:13 server.example.com /usr/sbin/amavisd-new[13635]: perl=5.020002, user=, EUID: 119 (119);  group=, EGID: 126 126 (126 126)
Aug 27 06:58:17 server.example.com /usr/sbin/amavisd-new[13635]: INFO: no optional modules: unicore::lib::Perl::SpacePer.pl unicore::lib::Nt::De.pl Unix::Getrusage
Aug 27 06:58:17 server.example.com /usr/sbin/amavisd-new[13635]: SpamControl: attempting to load scanner SpamAssassin, module Amavis::SpamControl::SpamAssassin
Aug 27 06:58:17 server.example.com /usr/sbin/amavisd-new[13635]: SpamControl: scanner SpamAssassin, module Amavis::SpamControl::SpamAssassin
Aug 27 06:58:24 server.example.com /usr/sbin/amavisd-new[2496]: (02496-01) SpamControl: rundown_child on SpamAssassin done
Aug 27 06:58:24 server.example.com /usr/sbin/amavisd-new[2495]: SpamControl: rundown_child on SpamAssassin done
Aug 27 06:58:24 server.example.com /usr/sbin/amavisd-new[2496]: (02496-01) child_finish_hook: invoking DESTROY methods
Aug 27 06:58:24 server.example.com /usr/sbin/amavisd-new[2495]: child_finish_hook: invoking DESTROY methods
Aug 27 06:58:24 server.example.com /usr/sbin/amavisd-new[13635]: INFO: SA version: 3.4.1, 3.004001, no optional modules: Net::CIDR::Lite Encode::Detect Image::Info Image::Info::GIF Image::Info::JPEG Image::Info::PNG Image::Info::BMP Image::Info::TIFF
Aug 27 06:58:24 server.example.com /usr/sbin/amavisd-new[13635]: SpamControl: init_pre_chroot on SpamAssassin done
Aug 27 06:58:24 server.example.com /usr/sbin/amavisd-new[13635]: socket module IO::Socket::IP, protocol families available: INET, INET6
Aug 27 06:58:24 server.example.com /usr/sbin/amavisd-new[13635]: bind to /var/lib/amavis/amavisd.sock|unix, 127.0.0.1:10024/tcp, [::1]:10024/tcp
Aug 27 06:58:24 server.example.com /usr/sbin/amavisd-new[13643]: Net::Server: Process Backgrounded
Aug 27 06:58:24 server.example.com /usr/sbin/amavisd-new[13643]: Net::Server: 2016/08/27-06:58:24 Amavis (type Net::Server::PreForkSimple) starting! pid(13643)
Aug 27 06:58:24 server.example.com /usr/sbin/amavisd-new[13643]: Net::Server: Binding to UNIX socket file "/var/lib/amavis/amavisd.sock"
Aug 27 06:58:24 server.example.com /usr/sbin/amavisd-new[13643]: Net::Server: Binding to TCP port 10024 on host 127.0.0.1 with IPv4
Aug 27 06:58:24 server.example.com /usr/sbin/amavisd-new[13643]: (!)Net::Server: 2016/08/27-06:58:24 Can't connect to TCP port 10024 on 127.0.0.1 [Address already in use]\n  at line 68 in file /usr/share/perl5/Net/Server/Proto/TCP.pm
Aug 27 06:58:24 server.example.com /usr/sbin/amavisd-new[13643]: Net::Server: 2016/08/27-06:58:24 Server closing!
Aug 27 06:58:26 server.example.com /usr/sbin/amavisd-new[2496]: (02496-01) TempDir::DESTROY called
Aug 27 06:58:32 server.example.com /usr/sbin/amavisd-new[2495]: Amavis::DB::SNMP DESTROY called
Aug 27 06:58:32 server.example.com /usr/sbin/amavisd-new[2496]: (02496-01) Amavis::DB::SNMP DESTROY called

Any help is highly appreciated. Thanks in advance!
EDIT:
systemctl status amavis.service gives the following:
● amavis.service - LSB: Starts amavisd-new mailfilter
   Loaded: loaded (/etc/init.d/amavis; generated; vendor preset: enabled)
   Active: active (exited) since Do 2016-12-01 07:06:25 CET; 5h 41min ago
     Docs: man:systemd-sysv-generator(8)
  Process: 6971 ExecStop=/etc/init.d/amavis stop (code=exited, status=0/SUCCESS)
  Process: 6981 ExecStart=/etc/init.d/amavis start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/amavis.service

Dez 01 07:06:03 server systemd[1]: Starting LSB: Starts amavisd-new mailfilter...
Dez 01 07:06:14 server amavis[6987]: starting. /usr/sbin/amavisd-new at server.example.com amavisd-new-2.10.1 (20141025), Unicode aware, LC_AL
Dez 01 07:06:25 server amavis[7000]: (!)Net::Server: 2016/12/01-07:06:25 Can't connect to TCP port 10024 on 127.0.0.1 [Address already in use]\
Dez 01 07:06:27 server amavis[6981]: Starting amavisd: amavisd-new.
Dez 01 07:06:25 server systemd[1]: Started LSB: Starts amavisd-new mailfilter.

I scanned today's mail.log and found the following info:
Dec  1 07:05:55 server spamd[14187]: spamd: server hit by SIGHUP, restarting
Dec  1 07:05:56 server spamd[14187]: spamd: child [14196] killed successfully: interrupted, signal 2 (0002)
Dec  1 07:05:56 server spamd[14187]: spamd: child [14197] killed successfully: interrupted, signal 2 (0002)
Dec  1 07:06:02 server spamd[14187]: spamd: server socket closed, type IO::Socket::IP
Dec  1 07:06:03 server spamd[14187]: spamd: server socket closed, type IO::Socket::IP
Dec  1 07:06:13 server spamd[14187]: logger: removing stderr method
Dec  1 07:06:14 server amavis[6987]: starting. /usr/sbin/amavisd-new at server.example.com amavisd-new-2.10.1 (20141025), Unicode aware, LC_ALL="C", LANG="de_DE.UTF-8"
Dec  1 07:06:15 server spamd[6995]: zoom: able to use 342/342 'body_0' compiled rules (100%)
Dec  1 07:06:25 server amavis[7000]: (!)Net::Server: 2016/12/01-07:06:25 Can't connect to TCP port 10024 on 127.0.0.1 [Address already in use]\n  at line 68 in file /usr/share/perl5/Net/Server/Proto/TCP.pm
Dec  1 07:06:32 server spamd[6995]: spamd: server started on IO::Socket::IP [127.0.0.1]:783, IO::Socket::IP [::1]:783 (running version 3.4.0)
Dec  1 07:06:34 server spamd[6995]: spamd: server pid: 6995
Dec  1 07:06:34 server spamd[6995]: spamd: server successfully spawned child process, pid 7005
Dec  1 07:06:34 server spamd[6995]: spamd: server successfully spawned child process, pid 7006
Dec  1 07:06:34 server spamd[6995]: prefork: child states: II

This leads me to the idea that it might be spamd itself which restarts my amavis daemon. But how can I find out, what process always restarts spamd?

A: Where to dig deeper?
It's like two copies are starting at the same time... can you prevent systemd or whatever from starting amavisd-new and run it yourself from the command line?
See the man page. There's are debug modes and a foreground mode.
http://manpages.ubuntu.com/manpages/trusty/man8/amavisd-new.8.html
       debug  Runs amavisd-new in debug mode

       debug-sa
              Runs amavisd-new in spamassassin debug mode

       foreground
              Does not fork to background