text:
Q: Oracle SQL find unique id by date Hello Experts,
I am running Oracle 12c on Windows.
I have made a query to find any new id's and the date they were entered.  I wanted to know how you would change the query to include an exact date as part of the search instead of just scanning all the date records on the table.
My query:
select carid, inventory_date from car_source t where not exists
      (select carid from car_source t2 where t.carid = t2.carid and t.inventory_date != t2.inventory_date);

Table build:
CREATE TABLE "CAR_SOURCE"
   (    "COUNT_CARS" NUMBER(10,0),
   "EQUIPMENT_TYPE" VARCHAR2(100 BYTE),
   "LOCATION" VARCHAR2(500 BYTE),
   "INVENTORY_DATE" DATE,
   "COUNT_INVENTORY" VARCHAR2(3000 BYTE),
   "CARID" VARCHAR2(20 BYTE)
  ) SEGMENT CREATION IMMEDIATE
  PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
  NOCOMPRESS LOGGING
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
  BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "USERS" ;

Insert the rows:
    Insert into CAR_SOURCE    (COUNT_CARS,EQUIPMENT_TYPE,LOCATION,INVENTORY_DATE,COUNT_INVENTORY,CARID)    values (3,'Trans AM','London',to_date('04-JUL-19','DD-MON-RR'),null,'0001');
Insert into CAR_SOURCE (COUNT_CARS,EQUIPMENT_TYPE,LOCATION,INVENTORY_DATE,COUNT_INVENTORY,CARID) values (5,'Chevy Volt','London',to_date('30-AUG-19','DD-MON-RR'),null,'0002');
Insert into CAR_SOURCE (COUNT_CARS,EQUIPMENT_TYPE,LOCATION,INVENTORY_DATE,COUNT_INVENTORY,CARID) values (6,'Trans AM','coventry',to_date('07-SEP-19','DD-MON-RR'),null,'0001');
Insert into CAR_SOURCE (COUNT_CARS,EQUIPMENT_TYPE,LOCATION,INVENTORY_DATE,COUNT_INVENTORY,CARID) values (5,'Chevy Volt','coventry',to_date('02-SEP-19','DD-MON-RR'),null,'0002');
 Insert into CAR_SOURCE (COUNT_CARS,EQUIPMENT_TYPE,LOCATION,INVENTORY_DATE,COUNT_INVENTORY,CARID) values (8,'Rovers','coventry',to_date('07-SEP-19','DD-MON-RR'),null,'0003');
Insert into CAR_SOURCE (COUNT_CARS,EQUIPMENT_TYPE,LOCATION,INVENTORY_DATE,COUNT_INVENTORY,CARID) values (9,'Jaguars','coventry',to_date('07-SEP-19','DD-MON-RR'),null,'0004');
Insert into CAR_SOURCE (COUNT_CARS,EQUIPMENT_TYPE,LOCATION,INVENTORY_DATE,COUNT_INVENTORY,CARID) values (7,'Rovers','London',to_date('30-AUG-19','DD-MON-RR'),null,'0003');
Insert into CAR_SOURCE (COUNT_CARS,EQUIPMENT_TYPE,LOCATION,INVENTORY_DATE,COUNT_INVENTORY,CARID) values (10,'Escalade','London',to_date('17-SEP-19','DD-MON-RR'),null,'0005');
Insert into CAR_SOURCE (COUNT_CARS,EQUIPMENT_TYPE,LOCATION,INVENTORY_DATE,COUNT_INVENTORY,CARID) values (12,'Mustangs','London',to_date('11-SEP-19','DD-MON-RR'),null,'0006');
Insert into CAR_SOURCE (COUNT_CARS,EQUIPMENT_TYPE,LOCATION,INVENTORY_DATE,COUNT_INVENTORY,CARID) values (2,'Trans AM','Brummy',to_date('20-SEP-19','DD-MON-RR'),null,'0001');
Insert into CAR_SOURCE (COUNT_CARS,EQUIPMENT_TYPE,LOCATION,INVENTORY_DATE,COUNT_INVENTORY,CARID) values (5,'Limo','London',to_date('12-SEP-19','DD-MON-RR'),null,'0007');
Insert into CAR_SOURCE (COUNT_CARS,EQUIPMENT_TYPE,LOCATION,INVENTORY_DATE,COUNT_INVENTORY,CARID) values (2,'Lambo','Essex',to_date('19-SEP-19','DD-MON-RR'),null,'0008');
Insert into CAR_SOURCE (COUNT_CARS,EQUIPMENT_TYPE,LOCATION,INVENTORY_DATE,COUNT_INVENTORY,CARID) values (1,'Limo','London',to_date('19-SEP-19','DD-MON-RR'),null,'0007');
Insert into CAR_SOURCE (COUNT_CARS,EQUIPMENT_TYPE,LOCATION,INVENTORY_DATE,COUNT_INVENTORY,CARID) values (2,'Chevy Volt','London',to_date('19-SEP-19','DD-MON-RR'),null,'0002');

Results:

*

*carid   DATE
   0004    07-SEP-19
   0005    17-SEP-19
   0006    11-SEP-19
   0008    19-SEP-19

Let's say I wanted to query for a particular date '19-SEP-19', would I create an alias for the first query and join it to a second date query?
Any advice on how to pull this together would be very helpful.
Kindest regards,
Gilly

A: If you want to find ids entered on a particular date, you can use aggregation:
select car_id
from car_source
group by car_id
having min(inventory_date) = date '2019-09-19';

EXISTS is useful if you want all the records in the table.  However, if you just want the car_ids first entered on that date, then aggregation is a simple approach.


text:
Q: Is it possible to create a "weak export" in TypeScript One unfortunate thing about testing modular code is that sometimes you have to export things just to test them. This pollutes your code, and it also makes nice features like "unused variable" flags on the compiler or linter less valuable - if you remove a usage in your application, you may still have a usage in your tests.
One possible solution would be something like a "weak reference", where test code would refer to the thing it's testing, but with an explicit "linter, compiler: please don't count this reference as a usage" flag.
I checked both the tsc flags and tslint config documents, but didn't see anything. A) did I miss something? B) is this a good idea and how hard would it be to implement?
(Other solutions just aren't as nice. For example, you could not export things and then use rewire to do introspection on the module to get at private things. My understanding is that the tsc would not be able to follow such a reference.)
Thanks for your help.

A: Separate them in to a different module and that way you can  test it more easily. Say you have the following use case.
function a () {/* implementation */}
export function b () {
   //... code
   a()
  //..code
}

if 'a' was on a different module and required by 'b' your test can then directly require that module. It might also be useful to use inversion of control for module ('b') dependencies. This will allow you to inject mocks/ spys and test it better. In our a/b example it should look something like this.
import {a} from './a'
export function CreateB(aFunc:a = a){
  return function b(){
    //..code
    aFunc()
    //..code
  }
}

If you will provide a more concrete example I might be able to assist further help more.

redpajama_set_name: RedPajamaStackExchange


text:
Q: What's the best way to capture packets sent and received by my own android app? I'm a developer of a VOIP calling app who's trying to troubleshoot connectivity issues.
I'd like to ship something in production that uploads pcap traces of it's own calls - particularly ones that drop, have high amounts of noise, or other nastiness.
There seem to be external apps (some of which require root) for capturing the network traffic of all apps - but no library that I can embed in my app and ship to help me debug.
Is there an easy to use solution for this?

A: 1. Wireshark
Run Wireshark on your laptop and setup your laptop as a hotspot. Connect your device to your laptop's hotspot, then run. Wireshark will capture all packets.
2. ADB
adb root > remount > shell
$su > tcpdump -w /sdcard/tcp > [CTRL-C] to stop > exit
adb pull /sdcard/tcp

A: I reccomend you to use Charles (especially when you use https): https://jaanus.com/debugging-http-on-an-android-phone-or-tablet-with-charles-proxy-for-fun-and-profit/


text:
Q: All tmap::qtm() plot titles are appearing in a single plot rather than their own I am currently writing a .Rmd (R markdown document) on downloading and visualising the Local Authority Districts (LADs) and transport regions of the UK within Rstudio.
> R.version
               _
platform       x86_64-pc-linux-gnu
arch           x86_64
os             linux-gnu
system         x86_64, linux-gnu
status
major          4
minor          2.0
year           2022
month          04
day            22
svn rev        82229
language       R
version.string R version 4.2.0 (2022-04-22)

I am doing this in a .Rmd so that this document can be hosted on github as a vignette.
I am having an issue whereby I have four separate plots which should all have unique titles set with qtm(title = 'desired_title') as per the documentation, however all titles are being assigned to my first plot and none of the plots after, even though the other plots are building correctly (legend, polygon colours etc.)
I have been knitting the document locally to view my changes rather than uploading every edit to GH to visualise my edits (knitr version: 1.39)
Here are the steps to reproduce my issue
library(sf)
library(tmap)
library(dplyr)

# Download data from the openinfra repo
url_regions_lad = "https://github.com/udsleeds/openinfra/raw/main/data-small/lads_joined_2021.geojson"
url_transport_regions = "https://github.com/udsleeds/openinfra/raw/main/data-small/regions_new.geojson"

# Load data into a Simple Features frame
regions_lad = read_sf(url_regions_lad)
transport_regions = read_sf(url_transport_regions)

# Set tmap mode to interactive
tmap::tmap_mode('view') # After this, all tmap::qtm() plots will be interactive

# Here we create the interactive plots
sf::sf_use_s2(use_s2 = FALSE)
regions_lad %>% tmap::qtm(title = 'LADs of UK & NI')

# Here we create an interactive plot of all LADs, coloured by the region they reside in
tmap_options(max.categories = 78) # Increase max categories so every (78) transport region has its own colour
regions_lad %>% tmap::qtm(fill = 'Region_name', title = 'LADs of UK & NI coloured by region')

# Here we plot the transport regions of England
transport_regions %>% tmap::qtm(title = 'Transport regions of England')

# Here we create the coloured interactive plot of England's transport regions
transport_regions %>% tmap::qtm(title = 'Coloured transport regions of England', fill = 'Region_name')

Note that sf::sf_use_s2(use_s2 = FALSE) is a fix for errors (1 2) due to an upgrade to the sf package
What I expect:
I expect to see each of the four plots with their own respective titles added
What I get:
Instead I have all four of my plot titles (the most recently created being the top title) added to the first plot and none after.
Single plot with all 4 titles on
The figures themselves are building correctly (This one has coloured all LADs) with the exception of titles, as can be seen in this example.
See the vignette hosted on GH here


text:
Q: Why is spritekit view hierarchy black? I am trying to debug my SpriteKit app and see its frames / positions. However, when I use the view hierarchy debugger, the screen is black. How do I resolve this?
Version 14.1 (14B47b)


text:
Q: How arbitrary is one? My teacher says our homework program must handle "an arbitrary number of input lines". It seems pretty arbitrary to only accept one line, but is it arbitrary enough? My roommate said seven is more a arbitrary number than one, and maybe he's right. But I just have no idea how to measure the arbitrariness of a number and Google doesn't seem to help.
UPDATE:
It sounds like maybe the best thing to do is accepty any given number of input lines, and hope the prof can see that that makes a lot more sense than insisting that the user just give you one specific arbitrary number of input lines. Especially since we weren't instructed to notify the user about what the arbitrary number is. You can't just make the user guess, that's crazy.

A: "Arbitrary" doesn't mean you get to pick a random number to accept. It means that it should handle an input with any number of lines.
So if someone decides to give your program an input with 0 lines, 1 line, 2 lines... n lines, then it should still do the right thing (and not crash).

A: Arbitrary means it could be ANY number. 0, 1, 7, 100124453225.
I would probably test for 0 and display some sort of error in that case since it's supposed to have SOME text. Other than that so long as there are more lines your program should keep doing whatever it's designed to do.

A: Typically when teachers indicate that a program should accept arbitrary amounts of input they are indicating to you that you should consider corner cases which you may not have thought about, one of the most common being no input at all which can often cause errors in programs if the programmer hasn't considered this case.
The point of the word is to emphasize that your program should be able to handle different inputs instead of simply crashing unless input comes in a certain quantity or is formatted in a specific way.


text:
Q: What is the difference between SVG and HTML5 Canvas? What are the differences between SVG and HTML5 Canvas? They both seem to do the same to me. Basically, they both draw vector artwork using coordinate points.
What am I missing? What are the major differences between SVG and HTML5 Canvas? Why should I choose one over the other?

A: SVG is like a "draw" program.  The drawing is specified as drawing instructions for each shape and any part of any shape can be changed.  Drawings are shape-oriented.
Canvas is like a "paint" program.  Once the pixels hit the screen, that is your drawing.  You cannot change shapes except by overwriting them with other pixels.  Paintings are pixel-oriented.
Being able to change drawings is very important for some programs; e.g. drafting apps, diagramming tools, etc. So SVG has an advantage here.
Being able to control individual pixels is important for some artistic programs.
Getting great animation performance for user-manipulation via mouse drags is easier with Canvas than SVG.
A single pixel on the computer screen will often consume 4 bytes of information and a computer screen these days takes several megabytes.  So Canvas might be inconvenient if you want to let the user edit an image and then upload it again.
By contrast, drawing a handful of shapes that cover the entire screen using SVG takes up few bytes, downloads quickly, and can be uploaded again easily with the same advantages going in that direction as when it comes down on the other direction.  So SVG can be faster than Canvas.
Google implemented Google Maps with SVG.  That gives the web app its zippy performance and smooth scrolling.

A: See Wikipedia: http://en.wikipedia.org/wiki/Canvas_element

SVG is an earlier standard for drawing
  shapes in browsers. However, SVG is at
  a fundamentally higher level because
  each drawn shape is remembered as an
  object in a scene graph or DOM, which
  is subsequently rendered to a bit map.
  This means that if attributes of an
  SVG object are changed, the browser
  can automatically re-render the scene.
In the example above, once the
  rectangle is drawn, the fact that it
  was drawn is forgotten by the system.
  If its position were to be changed,
  the entire scene would need to be
  redrawn, including any objects that
  might have been covered by the
  rectangle. But in the equivalent SVG
  case, one could simply change the
  position attributes of the rectangle
  and the browser would determine how to
  repaint it. It is also possible to
  paint a canvas in layers and then
  recreate specific layers.
SVG images are represented in XML, and
  complex scenes can be created and
  maintained with XML editing tools.
The SVG scene graph enables event
  handlers to be associated with
  objects, so a rectangle may respond to
  an onClick event. To get the same
  functionality with canvas, one must
  manually match the coordinates of the
  mouse click with the coordinates of
  the drawn rectangle to determine
  whether it was clicked.
Conceptually, canvas is a lower level
  protocol upon which SVG might be
  built.[citation needed] However, this
  is not (normally) the case—they are
  independent standards. The situation
  is complicated because there are scene
  graph libraries for Canvas, and SVG
  has some bit map manipulation
  functionality.

UPDATE:
I use SVG because of its markup language abilities - it can be processed by XSLT and can hold other markup in its nodes. Similarly I can hold SVG in my markup (chemistry). This allows me to manipulate SVG attributes (e.g. rendering) by combinations of markup. This may be possible in Canvas but I suspect that it's a lot harder.

A: It is absolutely depends on your need/requirement.

*

*If you want to just show an image/chart on a screen then recommended
approach is canvas. (Example is PNG, GIF, BMP etc.)

*If you want to extend the features of your graphics for example if you
mouse over on the chart want to zoom certain area without spoil
display quality then you select SVG. (Good example is AutoCAD, Visio,
GIS files).
If you want build a dynamic flow diagram creator tool with shape connector it is better to select SVG rather than CANVAS.

*

*When the size of the screen increases, canvas begins to degrade as
more pixels need to be drawn.

*When the number of objects increases on the screen, SVG begins to
degrade as we are continually adding them to the DOM.
Also please refer : http://msdn.microsoft.com/en-us/library/gg193983(v=vs.85).aspx

A: High Level Summary of Canvas vs. SVG
Canvas

*

*Pixel based (Dynamic .png)

*Single HTML element.(Inspect element in Developer tool. You can see only canvas tag)

*Modified through script only

*Event model/user interaction is granular (x,y)

*Performance is better with smaller surface, a larger number of objects (>10k), or both

SVG

*

*Shape based

*Multiple graphical elements, which become part of the DOM

*Modified through script and CSS

*Event model/user interaction is abstracted (rect, path)

*Performance is better with smaller number of objects (<10k), a larger surface, or both

For detailed difference, read http://msdn.microsoft.com/en-us/library/ie/gg193983(v=vs.85).aspx

A: SVG
Based on use case SVG is used for logos, charts because its vector graphics you draw and forgot about it. When view port change like re-sizing(or zoom) it will adjust itself and no need to redraw.
Canvas
Canvas is bitmap (or raster) it done by painting of pixels to the screen. It is used to develop games or graphics experience (https://www.chromeexperiments.com/webgl) in a given area it paints pixel and changes by redraw it another. Since its a raster type we need to redraw entirely as view port changes.
Reference
http://www.sitepoint.com/7-reasons-to-consider-svgs-instead-of-canvas
http://en.wikipedia.org/wiki/WebGL
http://vector-conversions.com/vectorizing/raster_vs_vector.html

A: There's a difference in what they are, and what they do for you.

*

*SVG is a document format for scalable vector graphics.

*Canvas is a javascript API for drawing vector graphics to a bitmap of a specific size.

To elaborate a bit, on format versus API:
With svg you can view, save and edit the file in many different tools. With canvas you just draw, and nothing is retained about what you just did apart from the resulting image on the screen. You can animate both, SVG handles the redrawing for you by just looking at the elements and attributes specified, while with canvas you have to redraw each frame yourself using the API. You can scale both, but SVG does it automatically, while with canvas again, you have to re-issue the drawing commands for the given size.

A: SVG is a specification of a drawing like a file format. A SVG is a document. You can exchange SVG files like HTML files. And additionally because SVG elements and HTML elements share the same the DOM API, it is possible to use JavaScript to generate a SVG DOM in the same way as it is possible to create a HTML DOM. But you do not need JavaScript to generate SVG file. A simple text editor is enough to write a SVG. But you need at least a calculator to calculate the coordinates of the shapes in the drawing.
CANVAS is just a drawing area. It it necessary to use JavaScript to generate the contents of a canvas. You can not exchange a canvas. It is no document. And the elements of the canvas are not part of the DOM tree. You can not use the DOM API to manipulate the contents of a canvas. Instead you have to use a dedicated canvas API to draw shapes into the canvas.
The advantage of a SVG is, that you can exchange the drawing as a document. The advantage of the CANVAS is, that is has a less verbose JavaScript API to generate the contents.
Here is an example, which shows that you can achieve similar results, but the way how to do it in JavaScript is very different.

// Italic S in SVG

(function () {

  const ns='http://www.w3.org/2000/svg';
  let s = document.querySelector('svg');
  let p = document.createElementNS (ns, 'path');
  p.setAttribute ('id', 'arc');
  p.setAttribute ('d', 'M 0.9 -0.9 a 0.8,0.4 -10 0,0 -0.9,0.9');
  s.appendChild (p);
  let u = document.createElementNS (ns, 'use');
  u.setAttribute ('href', '#arc');
  u.setAttribute ('transform', 'rotate(180)');
  s.appendChild (u);

})();

// Italic S in CANVAS

(function () {

  let c = document.querySelector('canvas');
  let w = c.width = c.clientWidth;
  let h = c.height = c.clientHeight;
  let x = c.getContext('2d');
  x.lineWidth = 0.05 * w;
  x.moveTo (w/2, h/2);
  x.bezierCurveTo (w*0.02, h*0.4,
                   w*0.4, -h*0.02,
                   w*0.95, h*0.05);
  x.moveTo (w/2, h/2);
  x.bezierCurveTo (w*(1-0.02), h*(1-0.4),
                   w*(1-0.4), h*(1+0.02),
                   w*(1-0.95), h*(1-0.05));
  x.stroke();

})();
svg, canvas {
  width: 3em;
  height: 3em;
}

svg {
  vertical-align: text-top;
  stroke: black;
  stroke-width: 0.1;
  fill: none;
}

canvas {
  vertical-align: text-bottom;
}

div {
  float: left;
}

<svg viewBox="-1 -1 2 2"></svg>VG

CANVA<canvas></canvas>

As you can see the result is almost the same, but the JavaScript code is completely different.
SVG is created with the DOM API using createElement, setAttribute and appendChild. All graphics are in the attribute strings. SVG has more powerful primitives. The CANVAS for example has nothing equivalent to the SVG arc path. The CANVAS example tries to emulate the SVG arc with a Bezier curve. In SVG you can reuse elements in order to transform them. In the CANVAS you can not reuse elements. Instead you have to write a JavaScript function in order to call it twice. SVG has a viewBox which allows to use normalized coordinates, which simplifies rotations. In the CANVAS you have to calculate the coordinates yourself based of the clientWidth and clientHeight. And you can style all SVG elements with CSS. In the CANVAS you can not style anything with CSS. Because SVG is a DOM, you can assign event handlers to all SVG elements. The elements in the CANVAS have no DOM and no DOM event handlers.
But on the other hand the CANVAS code is much easier to read. You do not need to care about XML name spaces. And you can directly call the graphics functions, because you do not need to build a DOM.
The lesson is clear: if you quickly want to draw some graphics, use the CANVAS. If you need to share the graphics, like to style it with CSS or want to use DOM event handlers in your graphics, build an SVG.

A: Two things that hit me the most for SVG and Canvas were,
Ability to use Canvas without the DOM, where as SVG depends heavily on DOM and as the complexity increases the performance slows down. Like in game design.
Advantage of using SVG would be that resolution remains the same across platforms which lacks in Canvas.
Lot more detail is provided in this site. http://dev.opera.com/articles/view/svg-or-canvas-choosing-between-the-two/

A: adding to the above points:
SVG is lightweight for transferring over web when compared to JPEG,GIF etc and also it scale extremely when resized without loosing the Quality.

A: SVG
It is Object Model-based.
Is suitable for using large rendering areas.
SVG provides any support for event handlers .
Modification is allowed through script and CSS.
SVG has Better scalability
SVG is Vector based (composed of shapes).
SVG is not suitable for Games graphics.
SVG does not depend on resolution.
SVG is capable for API animation.
SVG is suitable for printing with high quality and any resolution.
Canvas elements
It is pixel based.
Is suitable for using small rendering
Canvas does not provide any recourse for event handlers.
Modification is allowed through script only.
Canvas has poor scalability.
Canvas is Raster based (composed of a pixel).
Canvas is suitable for games graphics.
Canvas is completely dependent on resolution.
Canvas has no any API for animation.
Canvas is not suitable for printing high quality and high resolution.


text:
Q: Auto populate fields from one Vf Page to another VF page i have Two VF Pages(REGISTRATION PAGE,Questionnaire Page)in REGISTRATION PAGE i have one field called as email id i need that field to auto populate in Questionnaire Page is it possible any one please share your coding to achieve that..

A: use below code in your page navigation
 {! URLFOR($Page.Questionnaire, null, ['email'='email-you-want-to-send'] ) }

and use below code in your Questionnaire controller to get the email
 String email = apexpages.currentpage().getparameters().get('email');


text:
Q: Stylesheet taken-over/replaced by Chinese characters Okay, something just went crazy.  Unless China is taking over starting with my test style.css file on my iepage - well I guess they are starting off on the right foot hating on IE, but anyways. It loads with no stylesheet - sad :(  I go into the Web inspector and see that all my linked files are filled with [possibly] Chinese characters (瑨汭笠ऊ楷瑤...)  I have tried deleting the files on the server and re-uploading them. The local files look fine and when loading the files directly they look fine.  I didn't do anything that should of changed the rendering or anything either.

A: I encountered this same problem with XML files exported from PowerShell that were embedded in iFrames.
There was no issue in IE10/11 or Edge, but Firefox and Chrome wouldn't load the stylesheet.
The original page loading the iFrames was UTF8 encoded, same with the stylesheet. However, the XML file was exported to UTF16LE ("Unicode" in PowerShell). When the XML file was loaded from the iFrame, it loaded the stylesheet as Chinese characters.
I converted the encoding in PowerShell...
Get-Content C:\foldername\file.html -Encoding Unicode | Set-Content -Encoding UTF8 C:\foldername\file.html

...and it worked! My guess is that IE must treat the encoding of all files the same as the parent, which meant that the UTF16LE encoded file was rendered as UTF8. Chrome and Firefox apparently don't do that.
Thanks Xavier Holt for setting me on the right path!

A: So I think I figured it out.  This is weird.  But anyway.
I copied and pasted your HTML to a local file to experiment with.  And it loaded just fine.  It was saved as UTF-8.  Then I changed it to UTF-16, and I got exactly what you're seeing!  As far as  can tell, the browser (Firefox for Linux for me) is assuming the linked files are all in the same encoding as the HTML...
So - I assume the file on the server is in UTF-16, and if you change it to UTF-8 you should be good.  Hope that fixes it!
PS:  According to Firebug, your HTML is compressed by your server, even if you never explicitly told it to.  But that doesn't seem to be causing any problems, thankfully.

A: Another quick solution is to change the file encoding using Notepad.
Open the file in Notepad and Save As with the UTF-8 option selected from the drop down

A: it may be the .html file itself. I solved my similar problem by copying the contents of the original .html file and pasting it into a new file with the same name in the same directory (change the original's file name at first and delete the remainder of course)


text:
Q: How to find the sum of the first 21 terms of an Arithmetic Progression(A.P)?
Question. If the sum of first $12$ terms of an A.P. is equal to to the sum of the first $18$ terms of the same A.P., find the sum of the first $21$ terms of the same A.P.

$a=$ first term
$d=$ difference
I know now, $2(2a + 11d) = 3(2a + 17d)$
hence, $2a + 29d = 0$  --> correction
How do I proceed from here?

A: An arithmetic progression such that the sum of the first $12$ terms equals the sum of the first $18$ terms:
\begin{multline}
(-29) + (-27) + (-25) + (-23) + (-21) + (-19) +{} \\
  (-17) + (-15) + (-13) + (-11) + (-9) + (-7) = -216,\\
\end{multline}
\begin{multline}
(-29) + (-27) + (-25) + (-23) + (-21) + (-19) +{} \\
  (-17) + (-15) + (-13) + (-11) + (-9) + (-7) +{} \\
  (-5) + (-3) + (-1) + 1 + 3 + 5 = -216. \\
\end{multline}
The sum of the first $21$ terms of the series is
\begin{multline}
(-29) + (-27) + (-25) + (-23) + (-21) + (-19) +{} \\
  (-17) + (-15) + (-13) + (-11) + (-9) + (-7) +{} \\
  (-5) + (-3) + (-1) + 1 + 3 + 5 +7 + 9 + 11 = -189. \\
\end{multline}
So it is possible to do this with non-zero $a$ and $d,$ namely
$a = -29,$ $d = 2.$
By the distributive law, we have equality of the sum of the first $12$ terms and the sum of the first $18$ terms whenever $a = -29k$ and $d = 2k$
for some constant $k.$
And then the sum of the first $21$ terms is $-189k.$
So the sum of the first $21$ terms could be any real number if $k$ is allowed to be any real number. It can be any multiple of $189$ if the terms must all be integers.
I suspect an error in the transcription of the question, possibly before it was presented to you.


text:
Q: Monitor where SQS messages goes I was trying to monitor where and what consumes my messages in my SQS. I am using sqs-consumer to get all the messages available in my queues but the problem is I turned down the service that consumes those messages yet still being consume by a service and I don't know where. Is there a way to check where and what consumes the messages from my sqs queues ? Thank you!

A: https://aws.amazon.com/premiumsupport/knowledge-center/sqs-who-consumed-messages/
Copied directly from the above link:
It isn't possible to directly identify who consumes messages from Amazon SQS. However, client-side logging can provide some insight.

*

*Review the Amazon SQS resource policy. It's a best practice to implement least-privilege access and to verify that SQS queues aren't publicly accessible. Restrict the SQS queue ReceiveMessage action to specific AWS Identity and Access Management (IAM) users or roles. For more information, see Amazon SQS security best practices.

*Review all AWS Lambda function triggers for the SQS queue. If a Lambda function is configured with an active SQS event source, then it's possible that the Lambda function consumed the message.

To confirm who polled an SQS queue, contact AWS Support and provide a list of the following:

*

*Message IDs

*Request IDs

*Corresponding sent and received timestamps


text:
Q: what kind of password protection is suitable for admin interface? I have a project where the developer is building for me an admin interface that can be accessed from my domain, e.g.: domain.com/admin/.
Which kind of password protection should such an interface have?

*

*Simply put password protection on the /admin/ folder via Cpanel, which basically I Can do on my own.

*Make a built-in login screen for the interface.
Is there any difference? what are the considerations?

A: One way to protect your admin interface would be:

*

*Implement an access control restriction on the /admin url patterns, only those logged in as admin can access URLs containing this suffix

*Check in every page/view which is contained in the /admin folder whether the user is an administrator and has the right credentials

*Depending on your framework, implement good security practices like store only passwords in an encrypted form, prevent security leaks, implement session handling in a secure way, use already-made viable security tools(like PHP password_hash)


text:
Q: File icons blurry when loaded with an icon handler shell extension I have a shell extension with an icon handler that sets a file type's icons to a green or red icon, based on file contents. The icons seem to work properly except they are really blurry when using large icons, as if they were zoomed in from a really small size. The icon .ico files contain all image sizes from 256x256 to 16x16.

I am using a very basic icon handler, but maybe there could still be some problem with caching or something. How could I make sure the icons are loaded properly?
HRESULT icon_handler::GetIconLocation(UINT u_flags, PWSTR psz_icon_file, UINT cch_max, int* pi_index, UINT* pw_flags)
{
    *pw_flags = GIL_NOTFILENAME | GIL_DONTCACHE;
    return S_OK;
}

HRESULT icon_handler::Extract(PCWSTR psz_file, UINT n_icon_index, HICON* phicon_large, HICON* phicon_small, UINT n_icon_size)
{
    int icon = ICON_GREEN;
    if (m_icon_color_ == 1) {
        icon = ICON_RED;
    }

    if (phicon_large != nullptr)
    {
        const int large_size = LOWORD(n_icon_size);
        *phicon_large = HICON(LoadImageW(global_h_instance, MAKEINTRESOURCE(icon), IMAGE_ICON, large_size, large_size,
            LR_DEFAULTCOLOR));
    }
    if (phicon_small != nullptr)
    {
        const int small_size = HIWORD(n_icon_size);
        *phicon_small = HICON(LoadImageW(global_h_instance, MAKEINTRESOURCE(icon), IMAGE_ICON, small_size, small_size,
            LR_DEFAULTCOLOR));
    }

    return S_OK;
}

When logging with DebugView the icon handler appears to request appropriate sizes:
[30100] phicon_large size:
[30100] 256
[30100] phicon_small size:
[30100] 16

Edit:
As per @Anders, if I check the size of the image loaded with LoadImage it also appears to be correct:
*phicon_large = HICON(LoadImageW(global_h_instance, MAKEINTRESOURCE(icon), IMAGE_ICON, large_size, large_size,
            LR_DEFAULTCOLOR));
ICONINFOEXW info = {sizeof(ICONINFOEXW)};
GetIconInfoEx(*phicon_large, &info)
BITMAP bmp;
GetObjectW(info.hbmMask, sizeof(BITMAP), &bmp);
OutputDebugStringW(L"Icon size:");
OutputDebugStringW(std::to_wstring(bmp.bmWidth).c_str());

[12376] phicon_large size:
[12376] 256
[12376] Icon size:
[12376] 256
[12376] phicon_small size:
[12376] 16
[12376] Icon size:
[12376] 16

A: I've seen this kind of information from past documents.I can't guarantee that this information is accurate now.

nIconSize
Indicates the desired sizes of the icons. The high word is
  the dimensions (both height and width, since they're always the same)
  of the small icon, and the low word holds the dimensions of the of the
  large icon. Under normal circumstances, the small icon size will be
  16. The large icon will usually be 32 or 48, depending on which view mode Explorer is in - 32 for large icon mode, 48 for tile mode.

It seems that IExtract IconA:: Extract can only extract icons in standard sizes.
On the other hand, refer Raymond Chen's old thing,

if you ask IExtractIcon::Extract to extract an icon at a particular
  size, the function can return S_FALSE.The ExtractIcon and
  ExtractIconEx functions don't let you
  specify a custom size,
  and LoadImage doesn't work with icon indices
  (only resource IDs).

Therefore,If you need to extract icons of custom sizes (i.e., something other than the system's "small" and "large" sizes), then you'll need to do more work.
Call the SHGetImageList function, which is another shell helper function, but one that retrieves a shell image list containing icons. It gives you far more options for icon sizes: SHIL_SMALL (generally 16x16), SHIL_LARGE (generally 32x32), SHIL_EXTRALARGE (generally 48x48), and SHIL_JUMBO (generally 256x256—only on Vista and later). So if you ask for SHIL_EXTRALARGE, you'll get the 48x48 icons that you're looking for.
You'll still need the SHGetFileInfo function here, but this time it will be to retrieve the index of the desired icon in the shell image list. Retrieve that with the SHGFI_SYSICONINDEX option.
Completely untested sample code, never touched by a compiler:
HICON ExtractExtraLargeIcon(LPCTSTR pszPath)
{
    // Determine the index of the desired icon
    // in the system image list.
    SHGETFILEINFO sfi;
    SHGetFileInfo(pszPath, 0, &sfi, sizeof(sfi), SHGFI_SYSICONINDEX);

    // Retrieve the system image list.
    // (To get 256x256 icons, we use `SHIL_JUMBO`.)
    IImageList* piml;
    if (SHGetImageList(SHIL_JUMBO, IID_IImageList, (void**)&piml) == S_OK)
    {
        HICON hIcon;
        if (piml->GetIcon(sfi.iIcon, ILD_TRANSPARENT, &hIcon) == S_OK)
        {
           return hIcon;
        }
    }

    // Oops! We failed.
    return NULL;
}

More Details, please refer :
Difference between ExtractIcon and ExtractAssociatedIcon? Need to extract icon of specific size
Extract high resolution icon or thumbnail for file
Updated:
I accidentally found such a post, probably by specifying the width/height, remove LR_DEFAULTSIZE. Also, you must call DestroyIcon after DrawIconEx otherwise you get resource leak. Either that or create the HICON on heap so that it's created only once.


text:
Q: Templates not found in Flask Blueprint I'm working on an app using Blueprints and I followed the documentation quickstart on Blueprints, but still have a 404 on my templates.
I got an admin blueprint looking like that:
from flask import Blueprint, render_template

admin = Blueprint('admin', __name__, template_folder='templates')

@admin.route('/')
def admin_index():
    return render_template('admin/index.html.jinja2')

As described in the doc, my template is in /myapp/admin/templates/index.html.jinja2+
I register the blueprint in my app __init__.py file:
from flask import Flask
from . import config
from admin import admin

app = Flask(__name__)
app.config.from_object(config.DevelopmentConfig)

# register my blueprint
app.register_blueprint(admin, url_prefix='/admin/')

If anyone has an idea about a mistake I could have done, please tell me!

A: You are not accurate about docs. Your templates shoud be in
myapp/admin/templates/admin/index.html.jinja2

Note admin folder in templates.


text:
Q: Is there a way to disable webpack's default output when a module build fails? I'm struggling to find a way to disable webpack from outputting something like this when it comes across a SyntaxError.
throw new Error("Module build failed: SyntaxError: ...)

Ideally I would like it to output nothing instead of a throw.

A: I think webpack's bail option might be what you are looking for.  https://webpack.js.org/configuration/other-options/#bail  Bail will stop at the first sign of an error instead of tolerating the error.


text:
Q: Custom field in Linked Products woocommerce I found the following code to put the custom field in the linked products woocommerce function.
https://stackoverflow.com/a/45620800/9681621
Can someone please provide me the code to show the selected products in the cart page?

A: you should look some woocommerce documentation. https://docs.woocommerce.com/documentation/plugins/woocommerce/woocommerce-codex/theming/
you can follow these steps.
the woocommerce>templates>cart>cart.php is the cart page.
you will find something like this.
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
$_product   = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'],
$cart_item, $cart_item_key );
$product_id = apply_filters( 'woocommerce_cart_item_product_id',
$cart_item['product_id'], $cart_item, $cart_item_key );

loop display the products you added to the cart.Variable $product_id of the loop have the id of each product you added the the cart. now you can insert your custom field code here
echo get_post_meta( $product_id, 'my-field-slug', true );

it will look something like this.
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
$_product   = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'],
$cart_item, $cart_item_key );
$product_id = apply_filters( 'woocommerce_cart_item_product_id',
$cart_item['product_id'], $cart_item, $cart_item_key );

// Display Custom Field Value
// my-field-slug should be change according to your slug
echo get_post_meta( $product_id, 'my-field-slug', true );
}


text:
Q: How to make my website avalible on local network I'm currently working on my website which is running on nodejs usining expressjs, and everything is working fine. However I want to test my website from other devices, for example from my phone or other computer, which are connected to the same wi-fi. How am I supposed to do it? Thank you in advance.

A: disabling firewall is a bad idea. You can open a specific port or if you dont want to go through that, just use something like https://ngrok.io

A: You need to make sure that your websever computer is acccepting incomming request for this port, sometimes is necessary to set this up in the routing information on your router. disabling the firewall can also help with that if all of this is met by your computer other users should be able to get access to your server using your local Ip + port

A: Try to access your app with your locale ip address and your port. Something like that.
http://your.network.ip.address:port/ e.g. http://192.168.0.3:3000


text:
Q: Distinction between Mongodb Oplog and System Profiler I'm new to MongoDB and am trying to track operations on my database. Based on the documentation it seems like operations like inserts should be in both the oplog and profiler, but I only see it recorded in the profiler. For context, I am making inserts in the local database in a test collection (e.g. 'local.col'), but filtering for 'local.col' only yields results in the profiler output, not the oplog.
Based on this, I'm trying to understand the differences between the two tools, as I couldn't find anything on the internet addressing when oplog doesn't log operations.

A: Let's insert something..
db.getSiblingDB("local").oplog.rs.find().sort({ts:-1})
And then look what we have at oplog...
db.getSiblingDB("local").oplog.rs.find({"ns":"test.testi"})
{ "ts" : Timestamp(1516437458, 2), "t" : NumberLong(80), "h" : NumberLong("8404799607288492717"), "v" : 2, "op" : "i", "ns" : "test.testi", "o" : { "_id" : ObjectId("5a62ffd1c0d303fa808617bf") } }
You can see that we have insert operation (op) "i" with namespace (ns) "test.testi" and document (o) had only object id what system automatically added to empty document.
So, oplog records only changes. Which we can see here...
db.getSiblingDB("test").testi.update({"_id" : ObjectId("5a62ffd1c0d303fa808617bf") },{$set:{"other":"second"}})
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
what produces...
{ "ts" : Timestamp(1516437961, 1), "t" : NumberLong(80), "h" : NumberLong("-6648566515650969093"), "v" : 2, "op" : "u", "ns" : "test.testi", "o2" : { "_id" : ObjectId("5a62ffd1c0d303fa808617bf") }, "o" : { "$set" : { "other" : "second" } } }


text:
Q: Google Charts and Cordova I have a Cordova application that I want to add charting to.  I want to use Google Charts because they look the best (and free).  Anyone had any success using Google Charts on Cordova with the touch interactivity?  I saw a few questions posted a few years back that said they didn't work on Android but maybe they have evolved?

A: I stumbled across this GitHub repo some time ago while playing with Ionic (which is just another framework on top of Cordova).
https://github.com/saurabhgupta050890/ionic-chart-example
There's examples of how to use multiple chart libraries with AngularJS in Cordova. I'm not sure if this answers your question, but it suggests that it does work (though I haven't personally tried it). The only super big downside to using Google Charts API in this context, as opposed to some of the alternatives, is that you are forced to load them asynchronously from the Google server. This makes offline scenarios impossible.  If you are ok with users not being able to view charts while disconnected (for example, if they need to connect to a server to get the data anyway), then this shouldn't be a problem.
As to the question about Touch... Cordova is just a web browser with some fancy native features.  Load up the charts examples on your device and see if the charts do what you want them to. I haven't had any complaints from my business users on touch, but there are a few things you can't do the same way you do with a mouse.


text:
Q: How I can up the red message with CSS The form is generated by Bootsface and I want the red message is near to the input. The HTML is in: http://s2.subirimagenes.com/imagen/9590959sin-ttulo.png
The CSS code is:
#loginForm:inputUsuario, #loginForm:inputClave{
margin-bottom: 0;
padding-bottom: 0;
}

A XHTML fragment for the form is:
<h:outputLabel id = "txtUsuario" for = "inputUsuario" value = "#{msgs['loginForm.usuario']}"/>
<b:inputText id = "inputUsuario" required = "true" value = "#{logBean.nombre}" class = "inputText"/>
<h:message for = "inputUsuario" class = "text-danger text-center"/>
....

Is the space between b:inputText and h:message and I do not want this space


text:
Q: Why duplicate file descriptors rather than move them when swapping stdout with stderr in bash? I've seen this idiom around:
cmd 3>&1 1>&2 2>&3 3>&-

but my question is, why not just move them?
cmd 3>&1- 1>&2- 2>&3-

Is there a reason for this?


text:
Q: LINQ to SQL -Internals -C# Does LINQ to SQL work in connected environment or disconnected environment? I mean if you compile the query it builds expression query and the query is sent down to sql server ,there it is translated into T-SQL statement and executed and the final result is sent back to the C# code.I hope it is working in connected environment.Is there any framework operates LINQ to SQL in disconnected fashion?

A: It is connected when it needs to be - i.e. when querying data and when submit changes. If you supply a connection (to the overloaded constructor) that connection will be re-used, otherwise IIRC connection-pooling is used.
For fully disconnected, there are things like "sync services", which builds a local copy of the data.


text:
Q: Can I still sign apps with my certificates after my Apple Developer Program membership expires? I have an OSX app distributed through my website and not published to the Apple store.
I enrolled to the Apple developer program to get a signing certificate and sign my app.
Do I need to renew my membership to continue to sign my app?
Do the app signature will remains trusted by OS X?


text:
Q: how to work with directory in php the code is
<?php
$files = array();
$dir = opendir('/xampp/htdocs/myfun/template/home');
while(($file = readdir($dir)) !== false) {
    if($file !== '.' && $file !== '..') {
        $files[] = $file;
    }
}
closedir($dir);
//sort($files);
$i=0;
foreach($files as $key) {
    echo "";
    break;
}
?>

i want to show templates onclick  next/prev button.horizontally.
like slider.
please help

A: Correct logic to iterate a directory in while loop is false != ($file = readdir($dir)), where you assign file name first and check it's not false.
Also you can print title with $key itself. $files[$i] and $i variable is not required.
In order to iterate through all files of directory remove break, this will cause to end the loop after first iteration.
<?php
$files = array();
$dir = opendir('/xampp/htdocs/myfun/template/home');
while(false != ($file = readdir($dir)))
{
    if($file !== '.' && $file !== '..')
    {
        $files[] = $file;
    }
}
closedir($dir);
//sort($files);

foreach($files as $key)
{
    echo "";
}
?>


text:
Q: Refresh Angular 4 Component I've seen that this question already has been asked sometimes here on stackoverflow, but none of them seems to match my example.
I have two different json files. In my sidemenu, I have two buttons. By clicking on one of them, I want to display the data of the other json file I got. So in my view then, the data of the other file should be shown. I think I got it halfway, because when I click on the buttons, I can see in my console, that the other json file is loaded.
I'm switching and changing the files like this:
rest.ts
jsonFile = 'primarycolors.json'; // --> this file should be loaded at first (default file)
.
.
.
 // the buttons call this function
changeColorJson(name) {
    if(name === 'S'){
      this.jsonFile = 'secondarycolors.json';
      this.getDataFromJson(); // here I'm loading the function below. In my console then I can see, that this file was correctly loaded
    }
    else {
      this.jsonFile = 'primarycolors.json';
      this.getDataFromJson(); // same here
    }
}

getDataFromJson() {
    return new Promise(resolve => {
      this.http.get('../../assets/data/' + this.jsonFile) //here should be the path with the correct file
        .subscribe((data) => {
  resolve(data);
          console.log(data);
    });
  }

As you can see, I called the function getDataFromJson() in changeColorJson(name). I have a console log to show which json file is loaded and this works fine.
Now to my problem:
I'm calling getJsonDataFromJson() from the changeColorJson(name) function, where it loads the correct json file when I click on one of the buttons, but I am also calling getJsonDataFromJson() from the component I want to display the files in and there I'm calling the function only once, and then it doesn't get the new data. Now I'm asking, what can I do to refresh my color component? So it also gets the new data?
Here's my colors component:
colors.html
<div *ngFor="let color of colors">
  <p>{{color.name}}</p>
</div>

colors.ts
colors: any;
.
.
.
  getData() {
    this.restProvider.getDataFromJson() //the same function from above
      .then(data => {
        this.colors = data; //adding the data I got from json to colors

   // What can I do here to refresh the data I'm getting?
   });
}

A: You can use observables in order to detect the changes everywhere.
jsonFile = 'primarycolors.json'; // --> this file should be loaded at first (default file)
myData: Subject<any> = new Subject<any>();
.
.
.
 // the buttons call this function
changeColorJson(name) {
    if(name === 'S'){
      this.jsonFile = 'secondarycolors.json';
      this.getDataFromJson(); // here I'm loading the function below. In my console then I can see, that this file was correctly loaded
    }
    else {
      this.jsonFile = 'primarycolors.json';
      this.getDataFromJson(); // same here
    }
}

getDataFromJson() {
    this.http.get('../../assets/data/' + this.jsonFile) //here should be the path with the correct file
        .subscribe((data) => {
       this.myData.next(data)
    });

  }

and you need to subscribe to this variable
colors: any;
.
.
.
  getData() {
    this.restProvider.getDataFromJson() //the same function from above
    this.restProvider.myData.subscribe(data => {
      this.colors = data
    }
  }


text:
Q: Is there a way to quickly upload data on HDFS? I am trying to upload 4K files (approx) of size 5G each on HDFS for processing. I am using the command way to do this:
Iterating over each file -

hadoop fs -copyFromLocal "LocalPath" "HDFSPath"

It is taking a lot of time. Is there a faster way to do this? Does block size matter here?
Thanks in advance.

A: You can upload file in parallel by using background command by dividing 4k files into sets as per your cluster configuration.


text:
Q: How to write a function which has 2 nested functions inside and let computes sum / difference for any number of given items? I have to write a function which has 2 nested functions inside and computes only sum or difference of as many numbers as we want. Every equation end with "=". I wrote sth like this but it still doesn't work. What I am doing wrong?
def calculator(x: int):

    def operation(operator: str):

        def calculation(y: int):
            while operator != "=":
                if operators[i] == "=":
                    result -= digits[j]
                elif operators[i] == "+":
                    result += digits[j]
                else:
                    break
            return result
        return operator
    return calculator(result)

Function should work like that:
calculator(1)('+')(4)('-')(2)('=')

The result is 3. I can't use any package import or global variables.

A: You can also use a dictionary to define your operations, and make a very readable and simple function with space for expansion:
def calc(a: int): return lambda op: {
    '+': lambda b: calc(a+b),
    '-': lambda b: calc(a-b),
    '/': lambda b: calc(a/b),
    '*': lambda b: calc(a*b),
}.get(op, a)

print(calc(2)('+')(3)('-')(10)('/')(10)('*')(-100)('='))

A: Deducing from the form of the input, you need to return "functions" each time. One way of doing that is to use lambda:
def calculator(x: int):
    def operation(op: str, x: int):
        if op == '=':
            return x
        else:
            return lambda _: calculation(_, op, x)

    def calculation(y: int, op: str, x: int):
        if op == '+':
            return lambda _: operation(_, x + y)
        else:
            return lambda _: operation(_, x - y) # mind the order of x & y

    return lambda _: operation(_, x)

print(calculator(1)('+')(4)('-')(2)('=')) # 3
print(calculator(3)('-')(10)('+')(6)('=')) # -1

For example, consider calculator(1)('+')(4)('-')(2)('='). The first part calculator(1)('+') means that calculator(1) itself is a function, which is then to be applied with an argument ('+'). So calculator(x) need to return a function operation.
Also you might want to record the result (1 in this case), by passing it to operation; that's why I added a parameter x (meaning the current result) to operation. Then I used lambda x: operation(_, x) to return a "partial function".
By the same reasoning, operation returns calculation, which in turns returns operation and so on, until operation is given with '='.


text:
Q: Django documentation: Models; error from line 1 of code In the Django documentation on Models, the first command that I am asked to run and python's response was:
>>> from django.db import models

Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    from django.db import models
  File "C:\Python26\lib\site-packages\django\db\__init__.py", line 11, in <module>
        if DEFAULT_DB_ALIAS not in settings.DATABASES:
  File "C:\Python26\lib\site-packages\django\utils\functional.py", line 184, in inner
    self._setup()
  File "C:\Python26\lib\site-packages\django\conf\__init__.py", line 40, in _setup
    raise ImportError("Settings cannot be imported, because environment variable %s is             undefined." % ENVIRONMENT_VARIABLE)
ImportError: Settings cannot be imported, because environment variable     DJANGO_SETTINGS_MODULE is undefined.

As you can see from the stack trace, I am running a django server in python 2.6.6. Could anyone offer me a clue to start off on the right foot with this tutorial? Thanks in advance.

A: You're doing it wrong.
$ python manage.py shell

A: Are you running these commands from ./manage.py shell?  You cannot run django commands from the regular python shell without specifying where your settings.py file is for the project.  Django's ./manage.py shell command specifies that for you, making it easier to do django stuff on the command line.
If you don't see a file named manage.py in your current working directory, then that probably means you're not in the directory of your django application, or you haven't started one yet.
Edit: Also, that documentation is meant as an example of what to put in your application's models.py file, not something you should type in on the command line.  That doesn't mean it won't work on the command line (if you use manage.py shell) but it isn't what the documentation is suggesting.  Check the tutorial if you're unclear on how to start the shell and what files go where.

A: The answer here definitely works for the interactive prompt, which I was using, however I don't think that the intention of the first block of code was intended to actually be run! Immediately following that first code in the models documentation, you are expected to put the next codes into your models.py file created during the previous tutorial... I guess that's why they subtly labeled that section "Quick Example." What a headache!
Futhermore, that paragraph goes on to say "The above Person model would create a database table like..." suggesting that it was never intended to actually be run as-is.


text:
Q: Looking into getting into Python specifically for a project that involves threads and graphs I am well experienced in the C languages, but for a project that I have been assigned in one of my classes, I am considering using it as a project to introduce me into Python. I have never used Python before, but I have done some research, and it is very clear that GUI design and Visualizations come very easy to Python; however, I have been unable to find any libraries on threads.
My project is going to have two threads checking an object/class to see if a bool is set so that it can operate on some data and once it's turn is finished it will flag the other thread to operate on that same data. There will be several hundred logged data points on a graph that I will need to display graphically.
My questions are the following:

*

*Does Python have specific libraries that could help me display graphs with hundreds of points easily?
      If so, which would you recommend for a beginner in Python?

*Which thread libraries are best for beginners in Python?
Thank you all for any help in this matter.

A: igraph is good for graph visualisation. If you mean plotting points, use matplotlib.
threading module is built-in with python standard library.

A: You probably don't want threads in Python, as only one can run at a time. Search GIL (here or Google). There are modules like multiprocessing that allow easy use of multiple process based concurrency. The following creates two processes that print the strings passed in the args keyword arg. The biggest problem with multiprocessing is that, because it is multiprocess (and the processes have separate address spaces), shared objects have to be handled explicitly.
import multiprocessing as mp

def f(name):
  print name

p = mp.Process(target=f, args=('bob',))
q = mp.Process(target=f, args=('jeff',))
p.start()
q.start()
p.join()
q.join()

For graphing, see matplotlib. You can use it as a stand alone to just plot and show or you can embed it in a larger GUI library like QT. The following plots a line in matplotlib.
import matplotlib as plt

X = [0, 1, 2]
Y = [0, 1, 2]
plt.plot(X, Y)
plt.show()

It can also do pretty much any type of graph you can think of (scatter, histo, 3d surf/frame, contour, etc.).


text:
Q: Insert using stored procedure in mulitple table in C# ALTER PROCEDURE [dbo].[sp_CreateProcess]
   @type varchar(50),--0
   @HospitalID varchar(50),--1
   @PatientID varchar(50) ,--2
   @PreAuthorization varchar(50) ,--3
   @Status varchar(50) ,--4
   @Amount varchar(50) ,--5
   @AmtWords varchar(500) ,--6
   @AppTrt varchar(50) ,--7
   @TypeTrt varchar(50) ,--8
   @AilName varchar(100) ,--9
   @AilCode varchar(50) ,--10
   @RoomType varchar(50) ,--11
   @RoomRent varchar(50) ,--12
   @Signature varchar(50) ,--13
   @ProcessBy varchar(50) ,--14
   @CorpScheme varchar(50) ,--15
   @InsuranceDiv varchar(50) ,--16
   @DrRmk varchar(50) ,--17
   @Created_Date datetime ,--18
   @Modified_Date datetime ,--19
   @Created_By varchar(50) ,--20
   @Modified_By varchar(50) ,--21
   @CoRmk varchar(100) ,--22
   @Remark varchar(1500) ,--23
   @CreatedBy varchar(50) ,--24
   @ModifiedBy varchar(50) ,--25
   @CreatedDate datetime ,--26
   @ModifiedDate datetime, --27
   @UserRole int --28
AS
BEGIN
    if @type = 'insertProcess'
    begin
        insert into Patient_Process_Status values
        (
            @HospitalID,
            @PatientID,
            @PreAuthorization,
            @Status,
            @AilName,
            @AilCode,
            @RoomType,
            @RoomRent,
            @Signature,
            @ProcessBy,
            @CorpScheme,
            @InsuranceDiv,
            @DrRmk,
            CURRENT_TIMESTAMP,
            CURRENT_TIMESTAMP,
            @Created_By,
            @Modified_By
        )

        update dbo.UserCommunication set RoleID=@UserRole
        where PatientID=@PatientID  and  HospitalID=@HospitalID

        update PD_Patients set LastUpdatedRole=@UserRole
        where PatientID=@PatientID and  HospitalID=@HospitalID

        insert into PostEnhancetbl values
        (
            @PatientID,
            @HospitalID,
            @Amount,
            @AmtWords,
            @AppTrt,
            @TypeTrt ,
            @CoRmk,
            @Remark,
            @CreatedBy,
            @ModifiedBy,
            CURRENT_TIMESTAMP,
            CURRENT_TIMESTAMP
        )

    end

    if @type='getTPADetails'
    begin
        select PS.*,LastUpdatedRole from Patient_Process_Status PS
        left join PD_Patients PD on PS.PatientID=PD.PatientID  and  PS.HospitalID=PD.HospitalID
        where PS.PatientID=@PatientID  and  PS.HospitalID=@HospitalID
    end
END

This is the error I get:
**
The above code is my SQL Server 2014 stored procedure where I want to join two tables and insert my form value in 2 tables.
Please help me to resolve the issue and let me know why I am facing error of string to datetime conversion

A: The problem here is that you are passing a string type into a datetime parameter and it is failing to convert that string into datetime.
Check your parameters and make sure you pass a datetime format parameter value or you can use CONVERT in SQL Server side to convert the parameter into a proper and valid datetime format.
You could try using DateTime variableName instead of string variableName.
Hope this helps.


text:
Q: How Do I Locate the Order Confirmation Email Item Renderer? I'm having difficulty updating the order confirmation emails that our site is sending. I can find and modify the template in the admin interface and I can find the corresponding items.phtml file in on the server, but I can't seem to figure out where the individual items in the order are being rendered.
The items.phtml file contains the line:
$this->getItemHtml($_item)

which, as I understand things, must be calling a function to render the item's HTML for display. I've looked everywhere I can think of, but none of the files I try are resulting in any changes in the resulting emails.
Location of the aformentioned items.phtml file:
app/design/frontend/base/default/template/email/order/items.phtml

A Few of the Files I've tried:
app/design/frontend/base/default/template/email/order/items/order/default.phtml

app/design/frontend/default/myCompany/template/email/order/items/order/default.phtml

app/design/frontend/base/default/template/sales/order/items/renderer/default.phtml

app/design/frontend/default/myCompany/template/sales/order/items/renderer/default.phtml


text:
Q: ReportMissingImports -- Python virtual environment cant find my Imports I am trying to use a virtual environment in vscode, but when I set the interpreter to the file path in my venv folder it says that the imports can't be resolved? I am installing the packages via pip in my bash prompt outside of vscode.

A: I resolved it, selecting python interpreter in same folder venv; for select interpreter ctrl+shift+p


text:
Q: Detecting centers of circles from camera images So I'm developing an Ionic app that uses the phone camera to detect circles on fabric, like the picture below:

Where the max size is a 3x3 grid and there are 4 different colors (lightblue, darkblue, lightgreen and darkgreen). Basically, I've broken the problem down into 3 steps:

*

*Get the center of each circle.

*Get the color at the center of each circle

*Using the positions of each circle's center, create a representation of the pattern as a 2d array

My problem is figuring out the best way to achieve step 1. I've looked into the Hough Transform and I can't find very good resources for Javascript. If there is an easier or better way than using the Hough transform I would be very grateful to know.

A: You can use Image Segmentation with Watershed Algorithm which described in
here

A: In this type of image, you can do:

*

*Color thresholding in order to find each pattern

*(optional) opening + closing in order to clean a little bit your image if the thresholding result is not perfect.

*Connected component labeling (see the Union-Find algorithm) in order to separate each component.

*Then you have all the patterns, so you can easily find the centers and colors.


text:
Q: Asp.Net MVC: Fill a model property from a ActionFilterAttribute OnActionExecuting I'm implementing a captcha control for lost password in a website, like described here
But I feel very unconfortable with the             `

filterContext.ActionParameters["captchaValid"] =
  recaptchaResponse.IsValid;

Because:

*

*I've a strongly typed view, with validators

*The day I will change the property name without remembering this string field, it won't works.

So I searched how to edit an attribute of my model in the ActionFilterAttribute, in the OnActionExecuting, because my controller action will need this data.
I found this, but can't works for me since I need the model to be set BEFORE the action execute.
So I thought that I could add a "Post variable", which will be read by the model binder, but it seems that the filterContext.HttpContext.Request.Form is in read only mode.
So how do you think I could put the result in my model?
E.g: MyModel.IsCaptchaValid = recaptchaResponse.IsValid;
Event if I can't avoid to specify the property field, it's better than now:
filterContext.Something.Else["ModelKey"] = recaptchaResponse.IsValid;;

A: How about adding an error to ModelState e.g.
filterContext.Controller.ViewData.ModelState.AddModelError("", ""Captcha response invalid")

You can then check for ModelState.IsValid in your action (which you should be doing anyway)

A:
The day I will change the property name without remembering this
  string field, it won't works.

If you are worried about a property / string name change breaking the functionality, you could unit test your custom attribute.
public void CaptchaValidatorAttribute_SetsActionParameter_ForCaptchaValidity()
{
    // arrange
    var filterContext = new ActionExecutingContext
    {
        ActionParameters = new Dictionary<string, object>()
        // ... other arrangements, like mocking HttpContextBase and HttpRequestBase
    };
    var actionFilter = new CaptchaValidatorAttribute();

    // act
    actionFilter.OnActionExecuting(filterContext);

    // assert
    Assert.AreEqual(filterContext.ActionParameters.ContainsKey("captchaValid"),
        true);
}


text:
Q: Open user's Microsoft Word Application php I'm building a php application for intranet only use. I'm accessing network drives and listing the files.
Since chrome and FF do not have built-in functions to open Windows Explorer (I know there are extensions available). I was hoping to have php code recognize the file is a word application file (.doc, .docx, etc...) and then launch the user's Microsoft Word Application to open the file.
I've looked into PHPWord, but the documentation is terrible.
Is there a way (other than having each user download an extension) to be able to open a MS Word file using PHP?

A: PHPWord development is continued in github. Please checkout the latest version of the develop branch.

A: It looks like you're just wanting to stream a ms word doc to the browser and have the browser open the document in MS word.  That can be accomplished by setting the content type headers properly and then outputting the contents of the file.
This:
https://www.devside.net/wamp-server/forcing-a-pdf-or-doc-to-open-in-browser-rather-than-downloading
might help
Also, depending on browser and how it is streamed out, you might have an option in the browser to either Open the file, or save the file.  If you set the user's browsers to "open the file" then you are set.


text:
Q: R ggvis and shiny: layer_model_predictions(model = "lm") Error ... attempt to replicate an object of type 'closure' I tried to use ggvis with shiny, but got some error with my test sample. The codes are at the end of this message.
I got the following error message only when I tried to run ggvis with shiny:
Guessing formula = mpg ~ wt
Error in rep(col, length.out = nrow(data)) :
   attempt to replicate an object of type 'closure'

If I comment out the line in server.R
layer_model_predictions(model = "lm") %>%

I will not get the error message and shiny app runs fine except that I do not get the linear fitting lines. The ggvis part of the codes also run fine when not used with shiny. I guess it has something to do with the reactive data set by shiny, but I have no clue to find a quick fix.
Any suggestion?
Thanks a lot for the help!
Ying
ui.R
library(ggvis)
shinyUI(pageWithSidebar(

  div(),

  sidebarPanel(
    sliderInput("n", "Number of points", min = 1, max = nrow(mtcars),
                value = 10, step = 1)
  ),

  mainPanel(
    ggvisOutput("plot"),
    tableOutput("mtc_table")
  )

))

server.R
library(shiny)
library(ggvis)
library(dplyr)

shinyServer(function(input, output, session) {

  mtc <- reactive({

            mtc <- mtcars[1:input$n, ]
            mutate(mtc, carname=rownames(mtc), id = 1:nrow(mtc))
  })

  all_values <- function(x) {

      if(is.null(x)) return(NULL)
      row <- mtc()[mtc()$id == x$id, ]
      row$carname

  }

  mtc %>%
         ggvis(x= ~wt, y= ~mpg, key := ~id, fill = ~factor(cyl)) %>%
         layer_points() %>%
         group_by(cyl) %>%
         add_tooltip(all_values,"hover") %>%
         layer_model_predictions(model = "lm") %>%
         bind_shiny("plot")

  output$mtc_table <- renderTable({
    mtc()[, c("carname", "wt", "mpg", "cyl")]
  })
})


text:
Q: "Levelling" elevation data coinciding with polygon? I have a shapefile containing building geometries (polygons) and a elevation dataset. The elevation data doesn't perfectly match the buildings.
I want to "flatten" the elevation data so that wherever there's a building the elevation will be completely flat.
In short: For all pixels that intersect a polygon, alter their value to the average of the intersecting pixels.
How can I accomplish that?
This Question is more or less unrelated to a specific software, though I prefer using free software like QGIS, GDAL/OGR etc.

A: For mean values of elevation in building polygons...
In QGIS:

*

*Activate Zonal Statistics plugin

*

*Run it - "Raster/Zonal Statistics", it will add new columns to polygon layer

*the one needed is "mean".

*Duplicate your elevation layer (raster/grid) - you will use it for final file

*Use "Raster / Conversion / Rasterize"

*

*select you polygon (building) layer, field "mean"

*as target use your copy of elevation raster/grid.

*Keep existing size and resolution

*(for some reason my QGIS 2.2 vesion writes "The selected file is not a supported OGR format" for all vector files I tried so I needed to use QGIS dev version 2.3)

The result will be combination of original elevation values outside of polygons and mean inside of polygons.

A: This answer works only if you want constant value - in example 0.
In QGIS:

*

*Clip elevation by polygons (buildings) to new raster (grid) - buildings_grd

*

*Raster/Extraction/Clipper

*(Use Clipping mode "Mask Layer" and your building shapefile)

*Run raster calculator and calculate

*

*Raster/Raster Calculator...

*Expression: ("elevation" = "buildings_grd")*0 + ("elevation" != "buildings_grd")*"elevation"


text:
Q: How use Kendo UI Editor in asp.net mvc3 with razor? I'm using editor from Kendo UI, so I have big problem.
I don't know how display items which are returned by editor.
Editor convert something like:

to:
lt;p><img src="someurl"/></p>

and I keep converted string in database, and try display it with:
@Html.Raw(item.description)

where description is string returned by kendo.
So I have no idea how display it correctly in my View
Any help would be appreciated.

A: I found this solution for MVC:
in View

    @(Html.Kendo().EditorFor(model => model.HtmlField).Encode(false))
    @Html.ValidationMessageFor(model => model.HtmlField)

in model:
   [DataType(DataType.Html)]
   [AllowHtml]
   public string HtmlField{ get; set; }

That was enough

A: Simplier way to do it is make changes in controller, no in view and model. So:
View
$("#Editor").kendoEditor();

Model
public class MyModel
{
    public string Editor { get; set; }
}

Controller
Editor = Server.HtmlDecode(Editor);

HtmlDecode

A: There is an option of the KendeUI editor called encoded which configures whether the Editor should submit encoded HTML tags or not.
The default value for encoded is true
If you wan't to store the unencoded text use this sniplet when creating your editor:
$("#Editor").kendoEditor({
     encoded: false
 });

But because you are not sending encoded text to the server the Asp.net request validator kicks in and it will abort your request.
If you are using strongly typed views what you can do is to use the AllowHtmlAttribute on your model property:
View:
@model MyModel

@using(Html.BeginForm("SomeAction", "SomeController"))
{
     @Html.TextAreaFor(m => m.Editor)
     <input type="submit" value="Save" />
}

Model:
public class MyModel
{
    [AllowHtml]
    public string Editor { get; set; }
}

Controller action
public ActionResult SomeAction(MyModel myModel)
{
    //Save to db, etc.
}

You also need to set the following in your web.config or this attribute won't have effect in .NET 4.0:
<httpRuntime requestValidationMode="2.0"/>

A: The editor templates generated from the .NET Wrappers aren't working any more. Here is a fix.
http://pknopf.com/blog/kendo-ui-editor-templates-for-asp-net


text:
Q: MS SQL identify duplicate rows based on log time I have a fairly simple database table that logs every time a tray passes over an RFID reader. What sometimes happens is the data is being sent twice, so I have been asked if I can find out how often this happens. Rather than spending the next few days going through every record in the log table, I presume there must be a way of extracting this data using a SQL query?
For example, my data looks like this:

ID
TYPE
POINT
RFID
LOGGED

1
101
4101
1234
2021-01-20 06:31:25:154

2
101
4101
4567
2021-01-20 06:32:24:165

3
101
4102
1234
2021-01-20 06:35:55:154

4
101
4102
1234
2021-01-20 06:35:55:516

What I want to do is identify where I have duplicate RFID records where the POINT is the same and the time difference between the records is less than 5 seconds.
In the example above, IDs 3 & 4 would be returned as duplicate because they are both from POINT 4102, have the same RFID and the LOGGED difference is less than 5 seconds.
Although ID 1 has the same RFID (1234) as ID 3 & 4, this would not be a duplicate because the POINT is different.
I tried to write a query to return the duplicates, but I get no results, even though I have found some by looking through the table:
DECLARE @TheDate date
SET @TheDate = '2021-01-20'

SELECT
    [Type]
    ,[Point]
    ,[RFID]
    ,[Logged]
FROM
    [Log]
WHERE
    @TheDate = CONVERT(date,[Logged])
    AND [Point] IN ('4101', '4102')
    AND [Type] = '101'
GROUP BY
    [Type], [Point], [RFID], [Logged]
HAVING
    COUNT([RFID]) > 1

The other problem I have is that I have no idea how to do the datetime comparison to see if the difference in time is less than 5 seconds.

A: You can use lead() and lag().  For all such rows:
select l.*
from (select l.*,
             lag(logged) over (partition by rfid order by logged) as prev_logged,
             lead(logged) over (partition by rfid order by logged) as next_logged
      from logs l
     ) l
where prev_logged > dateadd(second, -5, logged) or
      next_logged < dateadd(second, 5, logged);

Your sample code looks like SQL Server so this uses SQL Server syntax.
If you just want the first record in a sequence of duplicates, you can use similar logic:
select l.*
from (select l.*,
             lag(logged) over (partition by rfid order by logged) as prev_logged,
             lead(logged) over (partition by rfid order by logged) as next_logged
      from logs l
     ) l
where (prev_logged < dateadd(second, -5, logged) or prev_logged is null) and
      next_logged < dateadd(second, 5, logged);

Note that both of these only use the rfid.  I'm not sure if the rfid should really be used in conjunction with other columns, such as point, but your question explicitly mentioned only duplicate rfid.


text:
Q: Unhandled and Uncatchable System.AccessViolationException While stress testing our application we always seem to suffer a catastrophic AccessViolationException after around 10-12 hours of use.
Using WinDbg to locate the source I see that it seems to originate from the native form's message loop. It would be great if someone would confirm my suspicion so I include a full stack trace with parameters. I have also taken a full stack trace if anyone needs more information.
Thanks in advance!

0:000> !CLRStack -p OS Thread Id: 0x748 (0) ESP       EIP
  0012d44c 7c90e514 [InlinedCallFrame: 0012d44c]
  System.Windows.Forms.UnsafeNativeMethods.WaitMessage() 0012d448
  7b1d8ed8
  System.Windows.Forms.Application+ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32,
  Int32, Int32)
      PARAMETERS:
          this = 0x015fe94c
          dwComponentID =
          reason = 0x00000004
          pvLoopData = 0x00000000
0012d4e4 7b1d89c7
  System.Windows.Forms.Application+ThreadContext.RunMessageLoopInner(Int32,
  System.Windows.Forms.ApplicationContext)
      PARAMETERS:
          this = 0x0153d9ec
          reason = 0x00000004
          context = 0x0226ec58
0012d538 7b1d8811
  System.Windows.Forms.Application+ThreadContext.RunMessageLoop(Int32,
  System.Windows.Forms.ApplicationContext)
      PARAMETERS:
          this =
          reason =
          context =
0012d568 7b6ede47
  System.Windows.Forms.Application.RunDialog(System.Windows.Forms.Form)
      PARAMETERS:
          form =
0012d57c 7b7225cb
  System.Windows.Forms.Form.ShowDialog(System.Windows.Forms.IWin32Window)
      PARAMETERS:
          this = 0x02265860
          owner =
0012d608 7b7227e3 System.Windows.Forms.Form.ShowDialog()
      PARAMETERS:
          this =
0012d60c 7b6eefa2
  System.Windows.Forms.Application+ThreadContext.OnThreadException(System.Exception)
      PARAMETERS:
          this = 0x0153d9ec
          t = 0x02265600
0012d648 7b6f7936
  System.Windows.Forms.Control.WndProcException(System.Exception)
      PARAMETERS:
          this =
          e =
0012d654 7b6fa3bc
  System.Windows.Forms.Control+ControlNativeWindow.OnThreadException(System.Exception)
      PARAMETERS:
          this =
          e =
0012d658 7b1c8502 System.Windows.Forms.NativeWindow.Callback(IntPtr,
  Int32, IntPtr, IntPtr)
      PARAMETERS:
          this = 0x01a9c930
          hWnd =
          msg = 0x00000002
          wparam =
          lparam =
0012e880 003c25e4 [NDirectMethodFrameStandalone: 0012e880]
  System.Windows.Forms.UnsafeNativeMethods.IntDestroyWindow(System.Runtime.InteropServices.HandleRef)
  0012e898 7b19ec50
  System.Windows.Forms.UnsafeNativeMethods.DestroyWindow(System.Runtime.InteropServices.HandleRef)
      PARAMETERS:
          hWnd =
0012e8a8 7b19eb5a System.Windows.Forms.NativeWindow.DestroyHandle()
      PARAMETERS:
          this = 0x01a96d08
0012e8ec 7b1b9050 System.Windows.Forms.Control.DestroyHandle()
      PARAMETERS:
          this = 0x01a967a8
0012e8f0 7b7226bc [InlinedCallFrame: 0012e8f0]  0012ea04 7b7227e3
  System.Windows.Forms.Form.ShowDialog()
      PARAMETERS:
          this =
0012ea08 04bf3a7b
  Workstation.FrontScreenForm.HandleNewEvent(GroupsRow, Int16, Int64)
      PARAMETERS:
          this = 0x0153b26c
          Group = 0x01a8de34
          EventTypeID = 0x00000003
          previousEventID = 0xffffffff
0012ec50 04bf344f
  Workstation.FrontScreenForm.HandleNewEvent(GroupsRow, Int16)
      PARAMETERS:
          this = 0x0153b26c
          Group = 0x01a8de34
          EventTypeID = 0x00000003
0012ec64 04b21ac4
  Workstation.FrontScreenForm.btnSiteCheck_Click(System.Object,
  System.EventArgs)
      PARAMETERS:
          this = 0x0153b26c
          sender = 0x01546a44
          e = 0x0153e990
0012ecd4 7b194180
  System.Windows.Forms.Control.OnClick(System.EventArgs)
      PARAMETERS:
          this =
          e =
0012ecec 7b18f56a
  System.Windows.Forms.Button.OnClick(System.EventArgs)
      PARAMETERS:
          this =
          e =
0012ecfc 7b734429
  System.Windows.Forms.ButtonBase.OnKeyUp(System.Windows.Forms.KeyEventArgs)
      PARAMETERS:
          this = 0x01546a44
          kevent = 0x01a914c0
0012ed0c 7b6f5bf1
  System.Windows.Forms.Control.ProcessKeyEventArgs(System.Windows.Forms.Message
  ByRef)
      PARAMETERS:
          this = 0x01546a44
          m = 0x0012ee44
0012ed5c 7b6f5c95
  System.Windows.Forms.Control.ProcessKeyMessage(System.Windows.Forms.Message
  ByRef)
      PARAMETERS:
          this =
          m =
0012ed6c 7b6f7381
  System.Windows.Forms.Control.WmKeyChar(System.Windows.Forms.Message
  ByRef)
      PARAMETERS:
          this = 0x01546a44
          m = 0x0012ee44
0012ed7c 7ba2a0ee
  System.Windows.Forms.Control.WndProc(System.Windows.Forms.Message
  ByRef)
      PARAMETERS:
          this =
          m =
0012ed80 7b1c2626 [InlinedCallFrame: 0012ed80]  0012ee18 7b1c25a0
  System.Windows.Forms.Button.WndProc(System.Windows.Forms.Message
  ByRef)
      PARAMETERS:
          this =
          m =
0012ee24 7b1c8690
  System.Windows.Forms.Control+ControlNativeWindow.OnMessage(System.Windows.Forms.Message
  ByRef)
      PARAMETERS:
          this =
          m =
0012ee2c 7b1c8611
  System.Windows.Forms.Control+ControlNativeWindow.WndProc(System.Windows.Forms.Message
  ByRef)
      PARAMETERS:
          this =
          m =
0012ee40 7b1c84ea System.Windows.Forms.NativeWindow.Callback(IntPtr,
  Int32, IntPtr, IntPtr)
      PARAMETERS:
          this = 0x01546b14
          hWnd =
          msg = 0x00000101
          wparam =
          lparam =
0012f220 003c25e4 [NDirectMethodFrameStandalone: 0012f220]
  System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG ByRef)
  0012f230 7b1d8d5e
  System.Windows.Forms.Application+ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32,
  Int32, Int32)
      PARAMETERS:
          this = 0x015fe94c
          dwComponentID =
          reason = 0xffffffff
          pvLoopData = 0x00000000
0012f2cc 7b1d89c7
  System.Windows.Forms.Application+ThreadContext.RunMessageLoopInner(Int32,
  System.Windows.Forms.ApplicationContext)
      PARAMETERS:
          this = 0x0153d9ec
          reason = 0xffffffff
          context = 0x015fdcd4
0012f320 7b1d8811
  System.Windows.Forms.Application+ThreadContext.RunMessageLoop(Int32,
  System.Windows.Forms.ApplicationContext)
      PARAMETERS:
          this =
          reason =
          context =
0012f350 7b195921
  System.Windows.Forms.Application.Run(System.Windows.Forms.Form)
      PARAMETERS:
          mainForm =
0012f364 00f809df Workstation.Program.Main() 0012f688 79e71b4c
  [GCFrame: 0012f688]

A: An access violation exception will not usually come from managed code, it means that your OS decided the process has done something bad (trying to access/change memory where it shouldn't) and should be terminated.
when you catch the exception with windbg (and take the dump) it is already too late.
some options:

*

*Use debugdiag to take a crash dump (this will get a dump in the right place, before the exception was thrown and the process started to deconstruct) Capturing crash dumps, Download DebugDiag 1.2

*look at the task manager after the process has run for a while and is expected to fail, (use select columns) check the GDI, handles, threads,User objects - these are all tracked resources and have limits the OS upholds, if one of them is high (in the thousands) this might be a problem.

*look at your code, check any points that use unmanaged objcts and verify they are correctly disposed. (using COMobjects is the most common way to access unmanaged resources and these can cause an access violation, as they use OS mem allocations directly)


text:
Q: Kubelet Not Starting: Crashing with Exit Status: 255/n/a Ubuntu 16.04 LTS, Docker 17.12.1, Kubernetes 1.10.0
Kubelet not starting:
Jun 22 06:45:57 dev-master systemd[1]: kubelet.service: Main process exited, code=exited, status=255/n/a
Jun 22 06:45:57 dev-master systemd[1]: kubelet.service: Failed with result 'exit-code'.
Note: No issue with v1.9.1
LOGS:
Jun 22 06:45:55 dev-master hyperkube[20051]: I0622 06:45:55.518085   20051 docker_service.go:249] Docker Info: &{ID:WDJK:3BCI:BGCM:VNF3:SXGW:XO5G:KJ3Z:EKIH:XGP7:XJGG:LFBL:YWAJ Containers:0 ContainersRunning:0 ContainersPaused:0 ContainersStopped:0 Images:1 Driver:btrfs DriverStatus:[[Build Version Btrfs v4.15.1] [Library Vers
Jun 22 06:45:55 dev-master hyperkube[20051]: I0622 06:45:55.521232   20051 docker_service.go:262] Setting cgroupDriver to cgroupfs
Jun 22 06:45:55 dev-master hyperkube[20051]: I0622 06:45:55.532834   20051 remote_runtime.go:43] Connecting to runtime service unix:///var/run/dockershim.sock
Jun 22 06:45:55 dev-master hyperkube[20051]: I0622 06:45:55.533812   20051 kuberuntime_manager.go:186] Container runtime docker initialized, version: 18.05.0-ce, apiVersion: 1.37.0
Jun 22 06:45:55 dev-master hyperkube[20051]: I0622 06:45:55.534071   20051 csi_plugin.go:61] kubernetes.io/csi: plugin initializing...
Jun 22 06:45:55 dev-master hyperkube[20051]: W0622 06:45:55.534846   20051 kubelet.go:903] Accelerators feature is deprecated and will be removed in v1.11. Please use device plugins instead. They can be enabled using the DevicePlugins feature gate.
Jun 22 06:45:55 dev-master hyperkube[20051]: W0622 06:45:55.535035   20051 kubelet.go:909] GPU manager init error: couldn't get a handle to the library: unable to open a handle to the library, GPU feature is disabled.
Jun 22 06:45:55 dev-master hyperkube[20051]: I0622 06:45:55.535082   20051 server.go:129] Starting to listen on 0.0.0.0:10250
Jun 22 06:45:55 dev-master hyperkube[20051]: E0622 06:45:55.535164   20051 kubelet.go:1282] Image garbage collection failed once. Stats initialization may not have completed yet: failed to get imageFs info: unable to find data for container /
Jun 22 06:45:55 dev-master hyperkube[20051]: I0622 06:45:55.535189   20051 server.go:944] Started kubelet
Jun 22 06:45:55 dev-master hyperkube[20051]: E0622 06:45:55.535555   20051 event.go:209] Unable to write event: 'Post https://10.50.50.201:8001/api/v1/namespaces/default/events: dial tcp 10.50.50.201:8001: getsockopt: connection refused' (may retry after sleeping)
Jun 22 06:45:55 dev-master hyperkube[20051]: I0622 06:45:55.535825   20051 fs_resource_analyzer.go:66] Starting FS ResourceAnalyzer
Jun 22 06:45:55 dev-master hyperkube[20051]: I0622 06:45:55.536202   20051 status_manager.go:140] Starting to sync pod status with apiserver
Jun 22 06:45:55 dev-master hyperkube[20051]: I0622 06:45:55.536253   20051 kubelet.go:1782] Starting kubelet main sync loop.
Jun 22 06:45:55 dev-master hyperkube[20051]: I0622 06:45:55.536285   20051 kubelet.go:1799] skipping pod synchronization - [container runtime is down PLEG is not healthy: pleg was last seen active 2562047h47m16.854775807s ago; threshold is 3m0s]
Jun 22 06:45:55 dev-master hyperkube[20051]: I0622 06:45:55.536464   20051 volume_manager.go:247] Starting Kubelet Volume Manager
Jun 22 06:45:55 dev-master hyperkube[20051]: I0622 06:45:55.536613   20051 desired_state_of_world_populator.go:129] Desired state populator starts to run
Jun 22 06:45:55 dev-master hyperkube[20051]: I0622 06:45:55.538574   20051 server.go:299] Adding debug handlers to kubelet server.
Jun 22 06:45:55 dev-master hyperkube[20051]: W0622 06:45:55.538664   20051 cni.go:171] Unable to update cni config: No networks found in /etc/cni/net.d
Jun 22 06:45:55 dev-master hyperkube[20051]: E0622 06:45:55.539199   20051 kubelet.go:2130] Container runtime network not ready: NetworkReady=false reason:NetworkPluginNotReady message:docker: network plugin is not ready: cni config uninitialized
Jun 22 06:45:55 dev-master hyperkube[20051]: I0622 06:45:55.636465   20051 kubelet.go:1799] skipping pod synchronization - [container runtime is down]
Jun 22 06:45:55 dev-master hyperkube[20051]: I0622 06:45:55.636795   20051 kubelet_node_status.go:289] Setting node annotation to enable volume controller attach/detach
Jun 22 06:45:55 dev-master hyperkube[20051]: I0622 06:45:55.638630   20051 kubelet_node_status.go:83] Attempting to register node 10.50.50.201
Jun 22 06:45:55 dev-master hyperkube[20051]: E0622 06:45:55.638954   20051 kubelet_node_status.go:107] Unable to register node "10.50.50.201" with API server: Post https://10.50.50.201:8001/api/v1/nodes: dial tcp 10.50.50.201:8001: getsockopt: connection refused
Jun 22 06:45:55 dev-master hyperkube[20051]: I0622 06:45:55.836686   20051 kubelet.go:1799] skipping pod synchronization - [container runtime is down]
Jun 22 06:45:55 dev-master hyperkube[20051]: I0622 06:45:55.839219   20051 kubelet_node_status.go:289] Setting node annotation to enable volume controller attach/detach
Jun 22 06:45:55 dev-master hyperkube[20051]: I0622 06:45:55.841028   20051 kubelet_node_status.go:83] Attempting to register node 10.50.50.201
Jun 22 06:45:55 dev-master hyperkube[20051]: E0622 06:45:55.841357   20051 kubelet_node_status.go:107] Unable to register node "10.50.50.201" with API server: Post https://10.50.50.201:8001/api/v1/nodes: dial tcp 10.50.50.201:8001: getsockopt: connection refused
Jun 22 06:45:56 dev-master hyperkube[20051]: I0622 06:45:56.236826   20051 kubelet.go:1799] skipping pod synchronization - [container runtime is down]
Jun 22 06:45:56 dev-master hyperkube[20051]: I0622 06:45:56.241590   20051 kubelet_node_status.go:289] Setting node annotation to enable volume controller attach/detach
Jun 22 06:45:56 dev-master hyperkube[20051]: I0622 06:45:56.245081   20051 kubelet_node_status.go:83] Attempting to register node 10.50.50.201
Jun 22 06:45:56 dev-master hyperkube[20051]: E0622 06:45:56.245475   20051 kubelet_node_status.go:107] Unable to register node "10.50.50.201" with API server: Post https://10.50.50.201:8001/api/v1/nodes: dial tcp 10.50.50.201:8001: getsockopt: connection refused
Jun 22 06:45:56 dev-master hyperkube[20051]: E0622 06:45:56.492206   20051 reflector.go:205] k8s.io/kubernetes/pkg/kubelet/kubelet.go:450: Failed to list *v1.Service: Get https://10.50.50.201:8001/api/v1/services?limit=500&resourceVersion=0: dial tcp 10.50.50.201:8001: getsockopt: connection refused
Jun 22 06:45:56 dev-master hyperkube[20051]: E0622 06:45:56.493216   20051 reflector.go:205] k8s.io/kubernetes/pkg/kubelet/config/apiserver.go:47: Failed to list *v1.Pod: Get https://10.50.50.201:8001/api/v1/pods?fieldSelector=spec.nodeName%3D10.50.50.201&limit=500&resourceVersion=0: dial tcp 10.50.50.201:8001: getsockopt: co
Jun 22 06:45:56 dev-master hyperkube[20051]: E0622 06:45:56.494240   20051 reflector.go:205] k8s.io/kubernetes/pkg/kubelet/kubelet.go:459: Failed to list *v1.Node: Get https://10.50.50.201:8001/api/v1/nodes?fieldSelector=metadata.name%3D10.50.50.201&limit=500&resourceVersion=0: dial tcp 10.50.50.201:8001: getsockopt: connecti
Jun 22 06:45:57 dev-master hyperkube[20051]: I0622 06:45:57.036893   20051 kubelet.go:1799] skipping pod synchronization - [container runtime is down]
Jun 22 06:45:57 dev-master hyperkube[20051]: I0622 06:45:57.045705   20051 kubelet_node_status.go:289] Setting node annotation to enable volume controller attach/detach
Jun 22 06:45:57 dev-master hyperkube[20051]: I0622 06:45:57.047489   20051 kubelet_node_status.go:83] Attempting to register node 10.50.50.201
Jun 22 06:45:57 dev-master hyperkube[20051]: E0622 06:45:57.047787   20051 kubelet_node_status.go:107] Unable to register node "10.50.50.201" with API server: Post https://10.50.50.201:8001/api/v1/nodes: dial tcp 10.50.50.201:8001: getsockopt: connection refused
Jun 22 06:45:57 dev-master hyperkube[20051]: E0622 06:45:57.413319   20051 event.go:209] Unable to write event: 'Post https://10.50.50.201:8001/api/v1/namespaces/default/events: dial tcp 10.50.50.201:8001: getsockopt: connection refused' (may retry after sleeping)
Jun 22 06:45:57 dev-master hyperkube[20051]: E0622 06:45:57.492781   20051 reflector.go:205] k8s.io/kubernetes/pkg/kubelet/kubelet.go:450: Failed to list *v1.Service: Get https://10.50.50.201:8001/api/v1/services?limit=500&resourceVersion=0: dial tcp 10.50.50.201:8001: getsockopt: connection refused
Jun 22 06:45:57 dev-master hyperkube[20051]: E0622 06:45:57.493560   20051 reflector.go:205] k8s.io/kubernetes/pkg/kubelet/config/apiserver.go:47: Failed to list *v1.Pod: Get https://10.50.50.201:8001/api/v1/pods?fieldSelector=spec.nodeName%3D10.50.50.201&limit=500&resourceVersion=0: dial tcp 10.50.50.201:8001: getsockopt: co
Jun 22 06:45:57 dev-master hyperkube[20051]: E0622 06:45:57.494574   20051 reflector.go:205] k8s.io/kubernetes/pkg/kubelet/kubelet.go:459: Failed to list *v1.Node: Get https://10.50.50.201:8001/api/v1/nodes?fieldSelector=metadata.name%3D10.50.50.201&limit=500&resourceVersion=0: dial tcp 10.50.50.201:8001: getsockopt: connecti
Jun 22 06:45:57 dev-master hyperkube[20051]: W0622 06:45:57.549477   20051 manager.go:340] Could not configure a source for OOM detection, disabling OOM events: open /dev/kmsg: no such file or directory
Jun 22 06:45:57 dev-master hyperkube[20051]: I0622 06:45:57.659932   20051 kubelet_node_status.go:289] Setting node annotation to enable volume controller attach/detach
Jun 22 06:45:57 dev-master hyperkube[20051]: I0622 06:45:57.661447   20051 cpu_manager.go:155] [cpumanager] starting with none policy
Jun 22 06:45:57 dev-master hyperkube[20051]: I0622 06:45:57.661459   20051 cpu_manager.go:156] [cpumanager] reconciling every 10s
Jun 22 06:45:57 dev-master hyperkube[20051]: I0622 06:45:57.661468   20051 policy_none.go:42] [cpumanager] none policy: Start
Jun 22 06:45:57 dev-master hyperkube[20051]: W0622 06:45:57.661523   20051 fs.go:539] stat failed on /dev/loop10 with error: no such file or directory
Jun 22 06:45:57 dev-master hyperkube[20051]: F0622 06:45:57.661535   20051 kubelet.go:1359] Failed to start ContainerManager failed to get rootfs info: failed to get device for dir "/var/lib/kubelet": could not find device with major: 0, minor: 126 in cached partitions map
Jun 22 06:45:57 dev-master systemd[1]: kubelet.service: Main process exited, code=exited, status=255/n/a
Jun 22 06:45:57 dev-master systemd[1]: kubelet.service: Failed with result 'exit-code'.

A: Run the following command on all your nodes. It worked for me.
 swapoff -a

A: I have found a lot of the same error messages in your logs:
dial tcp 10.50.50.201:8001: getsockopt: connection refused

There may be several problems:

*

*IP address and/or Port are incorrect

*no access from the Worker to the Master

*something wrong with your Master, for example, kube-apiserver is down

You should look in that direction.

A: user1188867's answer is definitely correct.
I want to add a piece of information for further reference for those not using Ubuntu.
I hit this on a cluster with Clear Linux on bare metal. I'm attaching here instructions on how to detect the issue in such environment and disable swap to solve.
First, launching sudo systemctl status kubelet after reboot produces the following:
● kubelet.service - kubelet: The Kubernetes Node Agent
    Loaded: loaded (/usr/lib/systemd/system/kubelet.service; enabled; vendor preset: disabled)
   Drop-In: /etc/systemd/system/kubelet.service.d
            └─0-cni.conf, 0-containerd.conf, 10-cgroup-driver.conf
    Active: activating (auto-restart) (Result: exit-code) since Thu 2020-12-17 11:04:37 CET; 2s ago
      Docs: http://kubernetes.io/docs/
   Process: 2404 ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS (code=exited, st>
   Process: 2405 ExecStartPost=/usr/bin/kubelet-version-check.sh store (code=exited, status=0/SUCCESS)
  Main PID: 2404 (code=exited, status=255/EXCEPTION)
       CPU: 683ms

The issue was actually the existence of the swap file.
To disable it:

*

*add the nofail option to /usr/lib/systemd/system/var-swapfile.swap. I personally used the following one-liner: sudo sed -i s/Options=/Options=nofail,/ /usr/lib/systemd/system/var-swapfile.swap

*Disable swapping: sudo swapoff -a

*Delete the swap file: sudo rm /var/swapfile
This procedure on Clear Linux persists the deactivation of the swap on reboots.

A: I had the same exit status, but my kubelet failed to start due to a limitation on the number of max_user_watches. The following got the kubelet working again
https://github.com/google/cadvisor/issues/1581#issuecomment-367616070

A: This problem can also arise if the service is not enabled after the Docker installation. After the next reboot, Docker is not started and kubelet cannot start either. So don't forget after the Docker installation:
sudo systemctl enable docker


text:
Q: delete a table form a database using laravel command i need to delete a database table using laravel artisan command .
not like this command php artisan migrate:rollback --step=5
i need to create like this route or controller code .
Route::get('/clear/database', function () {
    Artisan::call('cache:clear');
    return redirect('/');

});
. i also try
public function dd()
{
    Schema::drop('table_name');
}

but it not working . gives me error like this SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (SQL: drop table table_name)
no foreign key for the table .
what should i do ?
thanks in advance!

A: it's because one of your tables has a fk that is pointing to the table you are trying to delete
use Illuminate\Support\Facades\DB;

DB::statement('SET FOREIGN_KEY_CHECKS = 0');

Schema::dropIfExists('table');

// or

Artisan::call('command');

DB::statement('SET FOREIGN_KEY_CHECKS = 1');


text:
Q: Continuous Image Vertical Scroller I need to adjust the script from http://javascript.about.com/library/blcvert.htm to change direction of scrolling to DOWN.
Could anybody help?
Of course, it would be also helpful if anybody knows/have some other script which produces the same effect.
Thanx
P.S. the script (in readable format is):

    var imgAry1 = ['img1.png','img2.png'];

    function startCloud() {
       new mq('clouds', imgAry1, 380);
       mqRotate(mqr);
    }

    $(document).ready(function() {
        startCloud();
    });

    var mqr = [];

    function mq(id, ary, heit) {
    this.mqo=document.getElementById(id);
    var wid = this.mqo.style.width;
    this.mqo.onmouseout=function() { mqRotate(mqr); };
    this.mqo.onmouseover=function() { clearTimeout(mqr[0].TO); };
    this.mqo.ary=[];
    var maxw = ary.length;
    for (var i=0;i<maxw;i++) {
        this.mqo.ary[i]=document.createElement('img');
        this.mqo.ary[i].src=ary[i];
        this.mqo.ary[i].style.position = 'absolute';
        this.mqo.ary[i].style.top = (heit*i)+'px';
        this.mqo.ary[i].style.height = heit+'px';
        this.mqo.ary[i].style.width = wid;
        this.mqo.appendChild(this.mqo.ary[i]);
    }
    mqr.push(this.mqo);
    }

    function mqRotate(mqr) {
    if (!mqr) return;
    for (var j=mqr.length - 1; j > -1; j--) {
        maxa = mqr[j].ary.length;
        for (var i=0;i<maxa;i++) {
            var x = mqr[j].ary[i].style;
            x.top=(parseInt(x.top,10)-1)+'px';
        }
        var y = mqr[j].ary[0].style;
        if (parseInt(y.top,10)+parseInt(y.height,10)<0) {
            var z = mqr[j].ary.shift();
            z.style.top = (parseInt(z.style.top) + parseInt(z.style.height)*maxa) + 'px';
            mqr[j].ary.push(z);
        }
    }
    mqr[0].TO=setTimeout('mqRotate(mqr)',10);
    }

A: On this line:
x.top=(parseInt(x.top,10)-1)+'px';
it says that you take x.top in pixels, parse out the number, subtract one and add the 'px' again. The element's position from top is decreased by 1 each time, so it goes up. All you need to do for it to go down is to add the one.
x.top=(parseInt(x.top,10)+1)+'px';
I also tested this hypothesis on the page you linked :)