Tag Archives: JavaScript

We have rewritten SilverBench from Silverlight to JavaScript… and it works!

Microsoft killed Silverlight in 2012, and as you may have noticed the Internet Explorer is the last browser that supports it. So as the result, less and less users are using SilverBench to benchmark or stress test their PCs. Today we are launching SilverBench v2 rewritten entirely in the JavaScript, so you can now benchmark any device that has a web browser.

We have also taken a step further, and instead of Ray tracing we are now using Photon mapping. And Photon mapping is a way slower, so the Stress test runs even slower while still consuming 100% of all the CPU cores. Also, the Silverlight by design allowed us to use only one CPU socket. We are now using JavaScript Web Workers, and in theory this should scale across any number of CPU sockets, but we have not tested this yet.

SilverBench v2
SilverBench v2 · 2018
SilverBench v1
SilverBench v1 · 2010

Original source code taken from Kevin Beason’s smallpt project which we rewrote into JavaScript. More info and credits here.

How to execute JavaScript after inserting into element.innerHTML automatically

Here is a scenario:

  1. you have some software/component that inserts partial HTML into page using JavaScript element.innerHTML function;
  2. you can insert any HTML tags including <script>;
  3. you can not call any JS function (software/component does not have such functionality), and inserted script using innerHTML is not executed automatically.

After some lost time trying to come up with the solution, I found the following trick using image tag and onload attribute. Again if you try to use script tag, it will not work:
<script type="text/javascript">alert('testing')</script>
However code with image trick will execute JavaScript automatically:
<img src="/images/1x1-transparent.png" onload="alert('testing');this.parentNode.removeChild(this);" />

Note that removeChild, will remove just inserted image, so your HTML code stays unaffected.

Sources:

2011 links no. 3

Interview With Sacha Barber in The Code Project.

The ABA problem occurs during synchronization, when a location is read twice, has the same value for both reads, and “value is the same” is used to indicate “nothing has changed”. However, another thread can execute between the two reads and change the value, do other work, then change the value back, thus fooling the first thread in to thinking “nothing has changed” even though the second thread did work that violates that assumption.

An Idiot’s Guide to C++ Templates by Ajay Vijayvargiya from The Code Project.

C++0x Finally Becomes a Standard discussed in Slashdot.

What is Cloud Programming and why should we care By GanesanSenthilvel at The Code Project.

Interesting discussion in StackOverflow about Creating a memory leak with Java.

Why is subtracting two times (in 1927) is giving a strange result? or in Shanghai at midnight at the end of 1927, the clocks went back 5 minutes and 52 seconds. From StackOverflow.

$300M To Save 6 Milliseconds in high frequency trading discussed at Slashdot.

Age bias in IT: Some consider it IT’s dirty little secret, or even IT’s big open secret – from computerworld.com by Tam Harbert.

Am I Too Old To Learn New Programming Languages? from Slashdot and Become a Good Programmer in Six Really Hard Steps from ApochPiQ in GameDev.net.

InfoWorld writes about The nine circles of IT hell by Dan Tynan.

Biggest Mistakes in Web Design 1995-2015 from webpagesthatsuck.com.

From glyph recognition to augmented reality with video demos and source code By Andrew Kirillov in The Code Project.

Introduction to Google App Inventor by VinayakIyer from The Code Project.

Guide to Image Composition with Win32 MsImg32.dll By Paul Watt from The Code Project.

JavaScript Jargon (Coming to JavaScript from C#) By Jonathan Cardy.

Learn to code: Codecademy is the easiest way to learn how to code. It’s interactive, fun, and you can do it with your friends.

Minimalist Coding Guidelines By gggustafson.

Penrose Tiling in Obfuscated Python or Who says you can’t write obfuscated Python? from Jeff Preshing.

Learn Perl in about 2 hours 30 minutes By Sam Hughes.

PowerShell is powerful but can it handle gaming? PowerShell Falling Blocks By Lasse W.

Sudoku solver via a webcam: A nice computer vision application with source code from Bojan Banko.

Windows API: Slim Reader/Writer (SRW) Locks from MSDN (available from Vista and Server 2008).

The Five Levels of ISP Evil from Dane Jasper.

spin.js – cool open source JavaScript spinner hosted in GitHub.

Starting up inside the box (Vista and above) from Raymond Chen.

Stuxnet Malware Analysis Paper By AmrThabet. This article will focus on Stuxnet’s windows infection methods and spreading methods.

The Power of Rooting on Android By David Magnotti.

The Principles of Good Programming by Christopher Diggins.

.NET ThreadPool vs. Tasks by Paul Stovell.

Why does creating a shortcut to a file change its last-modified time… sometimes? from Raymond Chen.

Writing a Multiplayer Game (in WPF) By Paulo Zemek. This article will explain some concepts of game development and how to apply and adapt them for multiplayer development.