Friday 18 May 2018

casting - Why wasn't Tobey Maguire in The Amazing Spider-Man? - Movies & TV




In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man 2, Spider-Man 3. He also provided the voice of Spider-Man for the videogame adaptations of the films, but he wasn't in the recent release of Spider-Man series The Amazing Spider-Man.



Since his outstanding performance in the Spider-Man series, I was surprised. Why didn't Tobey Maguire get a chance to act in The Amazing Spider-Man?


Answer



The new Amazing Spider-Man is a reboot of the series. In other words, it has nothing to do with the earlier three movies. A few core elements remain, but the rest have been changed. So it only makes sense since they're giving the franchise a fresh start to give the role of Peter Parker to someone else.


Thursday 17 May 2018

identify this movie - Character Eaten by Monster from a Trap Door on the Floor - Movies & TV






The movie is in color and probably from the 1960s. I don't think it is Mysterious Island or Captain Nemo and the Underwater City.



The only scene I remember involves characters in a room, with wooden planks on the floor and the walls. The center is bare and prisoners face a group questioning them.



They are wearing what looks like pirate or sailor costumes from an earlier century.



At the center of the room is a trap door. After questioning one of the prisoners, one of the men opens the trap door, revealing the mouth of a monster. The prisoner is thrown into the trap door and is eaten by the monster, feet first.



Answer



The only other film that this remotely reminds me of is The Lost Continent from 1968.




This film starts out like the Love Boat on acid, as a cast of varied characters, with various issues, take Captain Eric Portman's leaky cargo ship to escape their troubles. When a violent storm strikes, the ship is swept into the Sargasso Sea and our heroes find themselves trapped on an island of man-eating seaweed, populated by giant monster crabs and some Spanish conquistadors who think the Inquisition is still on.



alphanumeric - How to generate unique six digit alpha-numeric code in Ruby



I need to generate a unique six digit alpha-numeric code. To save in my database as voucher no: for every transaction.


Answer



I used this



  require 'sha1'

srand
seed = "--#{rand(10000)}--#{Time.now}--"
Digest::SHA1.hexdigest(seed)[0,6]


How to generate a random string in Ruby This link was useful


ag-grid API Undefined in Angular 2



I am using the ag-grid API in an Angular 2 app, inside the ngOnInit method.



In the onGridReady event like mentioned in this post, the API is accessible and things work fine.




However, I need to call the API in one of the following methods as well:




  • onRowDataChanged

  • onNewColumnsLoaded

  • onModelUpdated



This is not working because the API is undefined. In addition, for some reason I can also call the API in the onCellDoubleClicked and onCellClicked events.




This seem to be a bug. Does anyone know what is going on?



Please see the code bellow:



ngOnInit() {

this.gridOptions = {

onGridReady: function (param) {

param.api.sizeColumnsToFit(); // works fine
},

onCellDoubleClicked: function (param) {
param.api.sizeColumnsToFit(); // works fine
},

onRowDataChanged: function (param) {
param.api.sizeColumnsToFit(); // API is undefined
},

};
}

Answer



Alright, here is how I got it working.




  • First, capture the this reference for your angular component just to make sure that you will not have JavaScript scoping issues.


  • Then, capture the API reference when it is available inside the onGridReady event


  • Lastly, only call the API after the stack is empty, deferring all the API calls with the setTimeout function





So now the code looks more or less like this:



...
let self = this;
...
onGridReady: function (param) {
self.api = param.api;
},


onRowDataChanged: function (param) {
setTimeout(() => {
self.api.sizeColumnsToFit()
...more API calls...
}, 0);
},
...

oracle - Icinga (nagios) trend of query result



I am setting up Icinga monitoring and after reading tons of documentation i still cant find out how to resolve the last aspect i need.




I need to execute a custom query on a Oracle datatabase on a extern network. The result of this query which will be a number (COUNT rows) I will have to save somehow in the Icinga database.



Then every 4 hours i want to execute a query that calculates the average of the results of query on the oracle database and have checks on these. Lets say if more then 50 then its critical if more then 40 then warning and so forth.




  1. How can I set up an event that calls the Oracle database every 5 minutes and saves the result in the Icinga database?


  2. How can I set up an event to read the information put in the database of Icinga? Suppose a query will suffice, i can calculate average with a query.




Thanks in advance! I love Icinga, but when things get complicated, it sometimes feels it comes short of solutions.




(Running on Ubuntu server, Icinga2 and Icinga web)


Answer



For icinga to query and store in the database use idoutils. COnfigure the required plugins for idodb which are modules of mysql. livestatus I think doesn't read or write in any database but is more prone to get live data and display it thats all.


matlab - Trying to optimize some code and make it faster

I have the following code in matlab, which is extremely slow.this code is related to my previous post in I as wondering is there any way to make matlab faster, also when I run the code it should show me figure, with updated images, but it doesnt show any thing




%% Loading Data
cd('D:\MatlabTest\15-07SpeedSensitivity\0.3');
clear all
row=101;
column=311;

%%
%Coefficients Creation
N=5;
W = [0.005 0.10;0.10 0.20;0.20 0.30;0.30 0.40;0.40 0.50;0.50 0.60 ;0.60 0.70;0.70 0.80 ;0.80 0.90;0.90 1.0];

for ind=1:9
wn = W(ind,:);
[b,a] = butter(N,wn);
bCoeff{ind}=b;
aCoeff{ind}=a;
end
[bCoeff{10},aCoeff{10}]=butter(N,0.9,'high');

%%
%filter initialization

ZState = cell(1,10);
for i=1:10
ZState{i} = zeros(max(length(aCoeff{i}), length(aCoeff{i})) - 1, 1); %# This is the initial filter state
end
%%
bands=10;
for b=1:bands
Yout{b}{row, column}=[];
end


%%
j=1;
K = 1000:4000;
window = zeros(1,10);
figure;
y = 0; %# Preallocate memory for output
j=0;
buffSize=10;
tempMean{row,column}=[];
Gibbs=(length(K)*3)/100;

fImg{1}(row,column)=0;
%load one image
for i = 1000:length(K)
disp(i)
str = int2str(i);
str1 = strcat(str,'.mat');
load(str1);
D(:,:) = A(100:200 ,200:510);
%go throught the columns and rows
for p = 1:row

for q = 1:column
%calculte the temporal mean value based on previous ones
if(size(tempMean{p,q}) tempMean{p,q}=[D(p,q) tempMean{p,q}];
else
tempMean{p,q}=[D(p,q) tempMean{p,q}(1:end-1)];
end
if(mean2(tempMean{p,q})==0)
x=0;
else

x = double(D(p,q)/mean2(tempMean{p,q}));
end
%filtering for 10 bands, based on the previous state
for f = 1:10
[y, ZState{f}] = filter(bCoeff{f},aCoeff{f},x,ZState{f});
if(j continue;
end
if(size(Yout{f}{p,q})<10)%init the first 10 after Gibbs phenomenon
Yout{f}{p,q} = [y.^2 Yout{f}{p,q}];

else
Yout{f}{p,q} = [y.^2 Yout{f}{p,q}(1:end-1)];
fImg{f}(p,q)=mean2(Yout{f}{p,q});
end
end
end
end
if(size(fImg{1}(1,1))>1)
for k = 1:10
subplot(5,2,1);

subimage(fImg{k}*5000, [0 0.5]);
colormap jet
end
pause(0.01);
end
j=j+1;
end
disp('Done Loading...')`

Javascript load Image into Offscreen Canvas, perform webp conversion



I recently used canvas to conert images to webp, using :




const dataUrl = canvas.toDataURL('image/webp');



But this takes a lots of time for certain images, like 400ms.



I got a warning from Chrome, since it is blocking UI.



I would like to use an Offscreen Canvas to perform that conversion in background.



But :




1) I don't know which Offscreen Canvas I should use :
a] new OffscreenCanvas()
b] canvas.transferControlToOffscreen()



2) I load a local image url in an Image object (img.src = url) to get width and height of the local image. But I don't understand how to transfert the Image object to the offscreen Canvas, to be able to do in the worker :



ctx.drawImage(img, 0, 0)



Because If I don't transfert the image, worker doesn't know img.



Answer



You are facing an XY and even -Z problem here, but each may have an useful answer, so let's dig in.






X. Do not use the canvas API to perform image format conversion.
The canvas API is lossy, whatever you do, you will loose information from your original image, even if you do pass it lossless images, the image drawn on the canvas will not be the same as this original image.
If you pass an already lossy format like JPEG, it will even add information that were not in the original image: the compression artifacts are now part of the raw bitmap, and export algo will treat these as information it should keep, making your file probably bigger than the JPEG file you fed it with.



Not knowing your use case, it's a bit hard to give you the perfect advice, but generally, make the different formats from the version the closest to the raw image, and once it's painted in a browser, you are already at least three steps too late.







Now, if you do some processing on this image, you may indeed want to export the results.
But you probably don't need this Web Worker here.
Y. What takes the biggest blocking time in your description should be the synchronous toDataURL() call.
Instead of this historical error in the API, you should always be using the asynchronous and nonetheless more performant toBlob() method. In 99% of the cases, you don't need a data URL anyway, almost all you want to do with a data URL should be done with a Blob directly.



Using this method, the only heavy synchronous operation remaining would be the painting on canvas, and unless you are downsizing some huge images, this should not take the 400ms.



But you can anyway make it even better on newest canvas thanks to createImageBitmap method, which allows you to prepare asynchronously your image so that the image's decoding be complete and all that needs to be done is really just a put pixels operation:






large.onclick = e => process('https://upload.wikimedia.org/wikipedia/commons/c/cf/Black_hole_-_Messier_87.jpg');
medium.onclick = e => process('https://upload.wikimedia.org/wikipedia/commons/thumb/c/cf/Black_hole_-_Messier_87.jpg/1280px-Black_hole_-_Messier_87.jpg');

function process(url) {
convertToWebp(url)
.then(prepareDownload)
.catch(console.error);
}

async function convertToWebp(url) {

if(!supportWebpExport())
console.warn("your browser doesn't support webp export, will default to png");

let img = await loadImage(url);
if(typeof window.createImageBitmap === 'function') {
img = await createImageBitmap(img);
}
const ctx = get2DContext(img.width, img.height);

console.time('only sync part');

ctx.drawImage(img, 0,0);
console.timeEnd('only sync part');

return new Promise((res, rej) => {
ctx.canvas.toBlob( blob => {
if(!blob) rej(ctx.canvas);
res(blob);
}, 'image/webp');
});
}


// some helpers

function loadImage(url) {
return new Promise((res, rej) => {
const img = new Image();
img.crossOrigin = 'anonymous';
img.src = url;
img.onload = e => res(img);
img.onerror = rej;

});
}

function get2DContext(width = 300, height=150) {
return Object.assign(
document.createElement('canvas'),
{width, height}
).getContext('2d');
}


function prepareDownload(blob) {
const a = document.createElement('a');
a.href = URL.createObjectURL(blob);
a.download = 'image.' + blob.type.replace('image/', '');
a.textContent = 'download';
document.body.append(a);
}

function supportWebpExport() {
return get2DContext(1,1).canvas

.toDataURL('image/webp')
.indexOf('image/webp') > -1;
}











Z. To draw an image on an OffscreenCanvas from a Web Worker, you will need the createImageBitmap mentioned above. Indeed, the ImageBitmap object produced by this method is the only image source value that drawImage() and texImage2D()(*) can accept which is available in Workers (all other being DOM Elements).



This ImageBitmap is transferable, so you could generate it from the main thread and then send it to you Worker with no memory cost:



main.js



const img = new Image();
img.onload = e => {
createImageBitmap(img).then(bmp => {

// transfer it to your worker
worker.postMessage({
image: bmp // the key to retrieve it in `event.data`
},
[bmp] // transfer it
);
};
img.src = url;



An other solution is to fetch your image's data from the Worker directly, and to generate the ImageBitmap object from the fetched Blob:



worker.js



const blob = await fetch(url).then(r => r.blob());
const img = await createImageBitmap(blob);
ctx.drawImage(img,0,0);






And note if you got the original image in your main's page as a Blob (e.g from an ), then don't even go the way of the HTMLImageElement, nor of the fetching, directly send this Blob and generate the ImageBitmap from it.



*texImage2D actually accepts more source image formats, such as TypedArrays, and ImageData objects, but these TypedArrays should represent the pixel data, just like an ImageData does, and in order to have this pixel data, you probably need to already have drawn the image somewhere using one of the other image source formats.


casting - Why wasn&#39;t Tobey Maguire in The Amazing Spider-Man? - Movies &amp; TV

In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...