tag:blogger.com,1999:blog-62655712334186019332024-03-18T21:21:31.664+01:00Cees's BlogCees Timmermanhttp://www.blogger.com/profile/09503128896817151851noreply@blogger.comBlogger35125tag:blogger.com,1999:blog-6265571233418601933.post-89012599398882879632024-03-18T21:12:00.000+01:002024-03-18T21:12:01.145+01:00Don't forget to check your integer type!<div data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="--darkreader-inline-bgcolor: #17191a; --darkreader-inline-color: #c8c3bc; background-color: #1f1f1f; color: #cccccc; font-family: Consolas, "Courier New", monospace; font-size: 14px; line-height: 19px; white-space: pre;"><div><span data-darkreader-inline-color="" style="--darkreader-inline-color: #cf947b; color: #ce9178;">"""PIL/Pillow Image.fromarray()</span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="--darkreader-inline-bgcolor: #17191a; --darkreader-inline-color: #cf947b; background-color: #1f1f1f; color: #ce9178;"> doesn't check your array value types!</span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="--darkreader-inline-bgcolor: #17191a; --darkreader-inline-color: #cf947b; background-color: #1f1f1f; color: #ce9178;">"""</span></div><br /><div><span data-darkreader-inline-color="" style="--darkreader-inline-color: #c688c1; color: #c586c0;">from</span> <span data-darkreader-inline-color="" style="--darkreader-inline-color: #5ccdb6; color: #4ec9b0;">PIL</span> <span data-darkreader-inline-color="" style="--darkreader-inline-color: #c688c1; color: #c586c0;">import</span> <span data-darkreader-inline-color="" style="--darkreader-inline-color: #5ccdb6; color: #4ec9b0;">Image</span></div><div><span data-darkreader-inline-color="" style="--darkreader-inline-color: #c688c1; color: #c586c0;">import</span> <span data-darkreader-inline-color="" style="--darkreader-inline-color: #5ccdb6; color: #4ec9b0;">numpy</span> <span data-darkreader-inline-color="" style="--darkreader-inline-color: #c688c1; color: #c586c0;">as</span> <span data-darkreader-inline-color="" style="--darkreader-inline-color: #5ccdb6; color: #4ec9b0;">np</span></div><br /><div><br /></div><div><span data-darkreader-inline-color="" style="--darkreader-inline-color: #87d5fe; color: #9cdcfe;">im</span> <span data-darkreader-inline-color="" style="--darkreader-inline-color: #cdc8c2; color: #d4d4d4;">=</span> <span data-darkreader-inline-color="" style="--darkreader-inline-color: #5ccdb6; color: #4ec9b0;">Image</span>.<span data-darkreader-inline-color="" style="--darkreader-inline-color: #d8d89f; color: #dcdcaa;">new</span>(<span data-darkreader-inline-color="" style="--darkreader-inline-color: #cf947b; color: #ce9178;">"RGB"</span>, (<span data-darkreader-inline-color="" style="--darkreader-inline-color: #afcaa1; color: #b5cea8;">2</span>, <span data-darkreader-inline-color="" style="--darkreader-inline-color: #afcaa1; color: #b5cea8;">1</span>))</div><div><span data-darkreader-inline-color="" style="--darkreader-inline-color: #87d5fe; color: #9cdcfe;">im</span>.<span data-darkreader-inline-color="" style="--darkreader-inline-color: #d8d89f; color: #dcdcaa;">putpixel</span>((<span data-darkreader-inline-color="" style="--darkreader-inline-color: #afcaa1; color: #b5cea8;">0</span>, <span data-darkreader-inline-color="" style="--darkreader-inline-color: #afcaa1; color: #b5cea8;">0</span>), (<span data-darkreader-inline-color="" style="--darkreader-inline-color: #afcaa1; color: #b5cea8;">255</span>, <span data-darkreader-inline-color="" style="--darkreader-inline-color: #afcaa1; color: #b5cea8;">0</span>, <span data-darkreader-inline-color="" style="--darkreader-inline-color: #afcaa1; color: #b5cea8;">0</span>))</div><div><span data-darkreader-inline-color="" style="--darkreader-inline-color: #87d5fe; color: #9cdcfe;">im</span>.<span data-darkreader-inline-color="" style="--darkreader-inline-color: #d8d89f; color: #dcdcaa;">putpixel</span>((<span data-darkreader-inline-color="" style="--darkreader-inline-color: #afcaa1; color: #b5cea8;">1</span>, <span data-darkreader-inline-color="" style="--darkreader-inline-color: #afcaa1; color: #b5cea8;">0</span>), (<span data-darkreader-inline-color="" style="--darkreader-inline-color: #afcaa1; color: #b5cea8;">0</span>, <span data-darkreader-inline-color="" style="--darkreader-inline-color: #afcaa1; color: #b5cea8;">255</span>, <span data-darkreader-inline-color="" style="--darkreader-inline-color: #afcaa1; color: #b5cea8;">0</span>))</div><br /><div><span data-darkreader-inline-color="" style="--darkreader-inline-color: #87d5fe; color: #9cdcfe;">a</span> <span data-darkreader-inline-color="" style="--darkreader-inline-color: #cdc8c2; color: #d4d4d4;">=</span> <span data-darkreader-inline-color="" style="--darkreader-inline-color: #5ccdb6; color: #4ec9b0;">np</span>.<span data-darkreader-inline-color="" style="--darkreader-inline-color: #d8d89f; color: #dcdcaa;">array</span>(<span data-darkreader-inline-color="" style="--darkreader-inline-color: #87d5fe; color: #9cdcfe;">im</span>)</div><div><span data-darkreader-inline-color="" style="--darkreader-inline-color: #d8d89f; color: #dcdcaa;">print</span>(<span data-darkreader-inline-color="" style="--darkreader-inline-color: #cf947b; color: #ce9178;">"Good shape:"</span>, <span data-darkreader-inline-color="" style="--darkreader-inline-color: #87d5fe; color: #9cdcfe;">a</span>.<span data-darkreader-inline-color="" style="--darkreader-inline-color: #87d5fe; color: #9cdcfe;">shape</span>, <span data-darkreader-inline-color="" style="--darkreader-inline-color: #87d5fe; color: #9cdcfe;">a</span>)</div><div><span data-darkreader-inline-color="" style="--darkreader-inline-color: #d8d89f; color: #dcdcaa;">print</span>(<span data-darkreader-inline-color="" style="--darkreader-inline-color: #cf947b; color: #ce9178;">"See?"</span>)</div><div><span data-darkreader-inline-color="" style="--darkreader-inline-color: #5ccdb6; color: #4ec9b0;">Image</span>.<span data-darkreader-inline-color="" style="--darkreader-inline-color: #d8d89f; color: #dcdcaa;">fromarray</span>(<span data-darkreader-inline-color="" style="--darkreader-inline-color: #87d5fe; color: #9cdcfe;">a</span>, <span data-darkreader-inline-color="" style="--darkreader-inline-color: #cf947b; color: #ce9178;">"RGB"</span>).<span data-darkreader-inline-color="" style="--darkreader-inline-color: #d8d89f; color: #dcdcaa;">show</span>()</div><br /><div><span data-darkreader-inline-color="" style="--darkreader-inline-color: #87d5fe; color: #9cdcfe;">a</span> <span data-darkreader-inline-color="" style="--darkreader-inline-color: #cdc8c2; color: #d4d4d4;">=</span> <span data-darkreader-inline-color="" style="--darkreader-inline-color: #5ccdb6; color: #4ec9b0;">np</span>.<span data-darkreader-inline-color="" style="--darkreader-inline-color: #d8d89f; color: #dcdcaa;">array</span>([[[<span data-darkreader-inline-color="" style="--darkreader-inline-color: #afcaa1; color: #b5cea8;">255</span>, <span data-darkreader-inline-color="" style="--darkreader-inline-color: #afcaa1; color: #b5cea8;">0</span>, <span data-darkreader-inline-color="" style="--darkreader-inline-color: #afcaa1; color: #b5cea8;">0</span>], [<span data-darkreader-inline-color="" style="--darkreader-inline-color: #afcaa1; color: #b5cea8;">0</span>, <span data-darkreader-inline-color="" style="--darkreader-inline-color: #afcaa1; color: #b5cea8;">255</span>, <span data-darkreader-inline-color="" style="--darkreader-inline-color: #afcaa1; color: #b5cea8;">0</span>]]])</div><div><span data-darkreader-inline-color="" style="--darkreader-inline-color: #d8d89f; color: #dcdcaa;">print</span>(<span data-darkreader-inline-color="" style="--darkreader-inline-color: #cf947b; color: #ce9178;">"Bad shape:"</span>, <span data-darkreader-inline-color="" style="--darkreader-inline-color: #87d5fe; color: #9cdcfe;">a</span>.<span data-darkreader-inline-color="" style="--darkreader-inline-color: #87d5fe; color: #9cdcfe;">shape</span>, <span data-darkreader-inline-color="" style="--darkreader-inline-color: #87d5fe; color: #9cdcfe;">a</span>)</div><div><span data-darkreader-inline-color="" style="--darkreader-inline-color: #d8d89f; color: #dcdcaa;">print</span>(<span data-darkreader-inline-color="" style="--darkreader-inline-color: #cf947b; color: #ce9178;">"Where'd the green pixel go?"</span>)</div><div><span data-darkreader-inline-color="" style="--darkreader-inline-color: #5ccdb6; color: #4ec9b0;">Image</span>.<span data-darkreader-inline-color="" style="--darkreader-inline-color: #d8d89f; color: #dcdcaa;">fromarray</span>(<span data-darkreader-inline-color="" style="--darkreader-inline-color: #87d5fe; color: #9cdcfe;">a</span>, <span data-darkreader-inline-color="" style="--darkreader-inline-color: #cf947b; color: #ce9178;">"RGB"</span>).<span data-darkreader-inline-color="" style="--darkreader-inline-color: #d8d89f; color: #dcdcaa;">show</span>()</div><br /><div><span data-darkreader-inline-color="" style="--darkreader-inline-color: #87d5fe; color: #9cdcfe;">a</span> <span data-darkreader-inline-color="" style="--darkreader-inline-color: #cdc8c2; color: #d4d4d4;">=</span> <span data-darkreader-inline-color="" style="--darkreader-inline-color: #5ccdb6; color: #4ec9b0;">np</span>.<span data-darkreader-inline-color="" style="--darkreader-inline-color: #87d5fe; color: #9cdcfe;">uint8</span>(<span data-darkreader-inline-color="" style="--darkreader-inline-color: #87d5fe; color: #9cdcfe;">a</span>)</div><div><span data-darkreader-inline-color="" style="--darkreader-inline-color: #d8d89f; color: #dcdcaa;">print</span>(<span data-darkreader-inline-color="" style="--darkreader-inline-color: #cf947b; color: #ce9178;">"Fixed shape:"</span>, <span data-darkreader-inline-color="" style="--darkreader-inline-color: #87d5fe; color: #9cdcfe;">a</span>.<span data-darkreader-inline-color="" style="--darkreader-inline-color: #87d5fe; color: #9cdcfe;">shape</span>, <span data-darkreader-inline-color="" style="--darkreader-inline-color: #87d5fe; color: #9cdcfe;">a</span>)</div><div><span data-darkreader-inline-color="" style="--darkreader-inline-color: #d8d89f; color: #dcdcaa;">print</span>(<span data-darkreader-inline-color="" style="--darkreader-inline-color: #cf947b; color: #ce9178;">"If the green pixel disappeared, you forgot to cast to uint8."</span>)</div><div><span data-darkreader-inline-color="" style="--darkreader-inline-color: #5ccdb6; color: #4ec9b0;">Image</span>.<span data-darkreader-inline-color="" style="--darkreader-inline-color: #d8d89f; color: #dcdcaa;">fromarray</span>(<span data-darkreader-inline-color="" style="--darkreader-inline-color: #87d5fe; color: #9cdcfe;">a</span>, <span data-darkreader-inline-color="" style="--darkreader-inline-color: #cf947b; color: #ce9178;">"RGB"</span>).<span data-darkreader-inline-color="" style="--darkreader-inline-color: #d8d89f; color: #dcdcaa;">show</span>()</div><br /></div>Cees Timmermanhttp://www.blogger.com/profile/09503128896817151851noreply@blogger.com0tag:blogger.com,1999:blog-6265571233418601933.post-33108851746115400262024-03-18T21:02:00.007+01:002024-03-18T21:21:00.926+01:00Coal ash contains more energy than was gained from burning the coal.<p>
<a href="https://www.world-nuclear.org/information-library/facts-and-figures/heat-values-of-various-fuels.aspx">https://www.world-nuclear.org/information-library/facts-and-figures/heat-values-of-various-fuels.aspx</a>
</p>
<table>
<tr>
<td>Natural uranium, in FNR</td>
<td>28,000 GJ/kg [so 28e9 J/g]</td>
</tr>
<tr>
<td>Hard black coal (IEA definition)</td>
<td>>23.9 MJ/kg</td>
</tr>
<tr>
<td>Hard black coal (Australia & Canada)</td>
<td>
c. 25 MJ/kg [so 25e3 J/g and 207.25 g/mol according to
https://pubchem.ncbi.nlm.nih.gov/compound/1-Anthrylmethanolate]
</td>
</tr>
<tr>
<td>Sub-bituminous coal (IEA definition)</td>
<td>17.4-23.9 MJ/kg</td>
</tr>
<tr>
<td>Sub-bituminous coal (Australia & Canada)</td>
<td>c. 18 MJ/kg</td>
</tr>
<tr>
<td>Lignite/brown coal (IEA definition)</td>
<td><17.4 MJ/kg</td>
</tr>
<tr>
<td>Lignite/brown coal (Australia, electricity)</td>
<td>c. 10 MJ/kg</td>
</tr>
</table>
<p><br /></p>
<p>mass / molar mass = moles</p>
<p>moles * avogardo = number of molecules</p>
<p><br /></p>
<p>number / avogadro = moles</p>
<p>moles * molar mass = mass</p>
<p><br /></p>
<p>
1e6 / 6.022140857e24 * 207.25 = 3.4414672e-17 g of coal = 8.603668e-13 J (25e3
J/g * 3.4414672e-17 g)
</p>
<p>
1 / 6.022140857e24 * 238.02891 = 3.952563e-23 g of uranium = 1.1067176e-12 J
(28e9 J/g * 3.952563e-23 g)
</p>
<p>
1 / 6.022140857e24 * 232.03806 = 3.8530826e-23 g of thorium = 1.0788631e-12 J
(28e9 J/g * 3.8530826e-23)
</p>
<p><br /></p>
<p>
<a href="https://pubs.usgs.gov/fs/1997/fs163-97/FS-163-97.html">https://pubs.usgs.gov/fs/1997/fs163-97/FS-163-97.html</a>
</p>
<p>
"2,000 coal samples from the Western United States and approximately 300 coals
from the Illinois Basin. In the majority of samples, concentrations of uranium
fall in the range from slightly below 1 to 4 parts per million (ppm). Similar
uranium concentrations are found in a variety of common rocks and soils, as
indicated in figure 2. Coals with more than 20 ppm uranium are rare in the
United States. Thorium concentrations in coal fall within a similar 1–4 ppm
range"
</p>
<p><br /></p>
<p>
So at 1 ppm uranium and 1 ppm thorium, a coal power plant releases only
(8.603668e-13 / (1.1067176e-12 + 1.0788631e-12)) = 0.3936559286 = 39% of the
available energy in coal.
</p>
Cees Timmermanhttp://www.blogger.com/profile/09503128896817151851noreply@blogger.com1tag:blogger.com,1999:blog-6265571233418601933.post-42344945745252563952020-05-29T12:15:00.003+02:002020-05-29T18:53:45.718+02:00Keep your system and project tidy with a Python virtual environment folder<pre><code class='bash'>
cees@cees-XPS-13-9380:~/code/space-monitor$ python3 -m venv venv
cees@cees-XPS-13-9380:~/code/space-monitor$ source venv/bin/activate
(venv) cees@cees-XPS-13-9380:~/code/space-monitor$ which python3
/home/cees/code/space-monitor/venv/bin/python3
(venv) cees@cees-XPS-13-9380:~/code/space-monitor$ python3 -m pip install logdna
Processing /home/cees/.cache/pip/wheels/af/ce/e9/fccf04ebc826e8cff5ec031f8ecc0c3b4092b44bc692f22a3f/logdna-1.5.3-py3-none-any.whl
Collecting requests
Using cached requests-2.23.0-py2.py3-none-any.whl (58 kB)
Collecting certifi>=2017.4.17
Using cached certifi-2020.4.5.1-py2.py3-none-any.whl (157 kB)
Collecting idna<3,>=2.5
Using cached idna-2.9-py2.py3-none-any.whl (58 kB)
Collecting urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1
Using cached urllib3-1.25.9-py2.py3-none-any.whl (126 kB)
Collecting chardet<4,>=3.0.2
Using cached chardet-3.0.4-py2.py3-none-any.whl (133 kB)
Installing collected packages: certifi, idna, urllib3, chardet, requests, logdna
Successfully installed certifi-2020.4.5.1 chardet-3.0.4 idna-2.9 logdna-1.5.3 requests-2.23.0 urllib3-1.25.9
(venv) cees@cees-XPS-13-9380:~/code/space-monitor$ python3 -m pip freeze > requirements.txt
(venv) cees@cees-XPS-13-9380:~/code/space-monitor$ cat requirements.txt
certifi==2020.4.5.1
chardet==3.0.4
idna==2.9
logdna==1.5.3
requests==2.23.0
urllib3==1.25.9
(venv) cees@cees-XPS-13-9380:~/code/space-monitor$ python3 -m pip install -r requirements.txt
Requirement already satisfied: certifi==2020.4.5.1 in ./venv/lib/python3.7/site-packages (from -r requirements.txt (line 1)) (2020.4.5.1)
Requirement already satisfied: chardet==3.0.4 in ./venv/lib/python3.7/site-packages (from -r requirements.txt (line 2)) (3.0.4)
Requirement already satisfied: idna==2.9 in ./venv/lib/python3.7/site-packages (from -r requirements.txt (line 3)) (2.9)
Requirement already satisfied: logdna==1.5.3 in ./venv/lib/python3.7/site-packages (from -r requirements.txt (line 4)) (1.5.3)
Requirement already satisfied: requests==2.23.0 in ./venv/lib/python3.7/site-packages (from -r requirements.txt (line 5)) (2.23.0)
Requirement already satisfied: urllib3==1.25.9 in ./venv/lib/python3.7/site-packages (from -r requirements.txt (line 6)) (1.25.9)
(venv) cees@cees-XPS-13-9380:~/code/space-monitor$ deactivate
cees@cees-XPS-13-9380:~/code/space-monitor$
</code></pre>Cees Timmermanhttp://www.blogger.com/profile/09503128896817151851noreply@blogger.com1tag:blogger.com,1999:blog-6265571233418601933.post-66115580422374425432020-02-27T18:32:00.004+01:002022-10-25T11:20:29.954+02:00Autocue / Teleprompter<div>
<button id="acbutton" onclick="toggle_cue(true)" title="Click to toggle">Autocue/teleprompt</button>
<label for="ac-slowness">Frame time </label><input id="ac-slowness" type="number" style="width:70px" value="30"> ms.
<label for="ac-scrollstep">Scroll step </label><input id="ac-scrollstep" type="number" style="width:60px" value="1"> px.
<label for="ac-padding">Padding </label><input id="ac-padding" style="width:70px" value="2in 4in" onchange="set_style()">
<label for="ac-font">Font </label><input id="ac-font" value="0.5in Georgia, serif" onchange="set_style()">
<label for="ac-transform">Transform </label><input id="ac-transform" style="width:90px" value="scale(-1, 1)" onchange="set_style()"
title="scale(-1, 1) to mirror">
<label for="autocue-content">Text </label>(from <a href="https://www.youtube.com/watch?v=YeRu4xYH_W0">here</a>): <br>
</div>
<textarea id="actext" class="styled-scrollbars" onclick="toggle_cue(false)">
You see, a teleprompter is nothing but a piece of glass in front of the lens, placed at a 45 degree angle.
This glass then reflects an image from some sort of display below it, allowing me, your host, to see it.
Sometimes a teleprompter has its display above the glass, but in this case it’s below.
This display can be pretty much anything at all.
In my case, it’s just a cheap tablet.
The only thing the display must be able to do is reverse the image so that it appears normally in the reflection.
You could simply practice reading backwards text;
I personally don’t find that to be all that difficult, but it is significantly easier to simply read normal words and not sdrawkcab era taht sdrow.
Of course, the key here is that the camera is looking through this piece of glass at me, your charming host.
This means that when I’m looking at the words,
I’m pretty much looking right at the camera lens.
</textarea>
<script>
var duration = 20
var scroller = null
const getel = id => document.getElementById(id)
const acc = getel('actext')
function set_style() {
acc.style.font = getel('ac-font').value
acc.style.padding = getel('ac-padding').value
acc.style.transform = getel('ac-transform').value
}
set_style()
function toggle_cue(on) {
acbutton.disabled = on
document.body.style.overflow = on?'hidden':'auto'
getel('actext').classList.toggle('full', on)
var scrollstep = parseInt(getel('ac-scrollstep').value)
if (on) scroller = setInterval(() => acc.scrollTop += scrollstep, getel('ac-slowness').value)
else clearInterval(scroller)
}
</script>
<style>
html {
--fgcolor: white;
--bgcolor: rgb(40,40,40);
background-color: var(--bgcolor);
color: var(--fgcolor);
}
body {
margin: 0;
}
#actext {
color: white;
background-color: black;
border: 2px solid red;
resize: none;
}
.full {
position: fixed;
left: 0;
right: 0;
top: 0;
bottom: 0;
z-index: 9000;
}
.styled-scrollbars {
overflow: auto;
scrollbar-color: var(--fgcolor) transparent;
scrollbar-width: thin;
}
.styled-scrollbars::-webkit-scrollbar {
width: 10px;
height: 10px;
}
.styled-scrollbars::-webkit-scrollbar-thumb, .styled-scrollbars::-webkit-scrollbar-corner {
background-color: var(--bgcolor);
border: 1px outset;
border-color: var(--fgcolor);
border-radius: 5px;
}
.styled-scrollbars::-webkit-scrollbar-thumb:hover {
border-width: 2px;
}
</style>Cees Timmermanhttp://www.blogger.com/profile/09503128896817151851noreply@blogger.com2tag:blogger.com,1999:blog-6265571233418601933.post-48912336641179604192019-05-07T10:58:00.001+02:002023-11-23T13:41:56.911+01:00Free Planning Poker<style>button.poker{height:25pt; font-size:15pt; vertical-align:middle; min-width:25pt}</style>
<span>
<script>
function poker(e){document.getElementById('poker').innerHTML=e.textContent}
for(let s of [0, '½', 1, 2, 3, 5, 8, 13, 20, 40, 100, 'XXS', 'XS', 'S', 'M', 'L', 'XL', 'XXL', '∞', '?', '☕']) document.write("<button class='poker' onclick='poker(this)'>"+s+"</button> ")
</script>
</span>
<div id="poker" style="color:black; font-size:96pt; width:100%; padding:100pt 0pt 100pt; text-align:center"></div>Cees Timmermanhttp://www.blogger.com/profile/09503128896817151851noreply@blogger.com6tag:blogger.com,1999:blog-6265571233418601933.post-68347830585766278202016-12-13T13:20:00.000+01:002018-02-28T17:01:02.682+01:00More infoI tend to more easily post tech news at <a href="https://gist.github.com/CTimmerman">GitHub Gist</a>, <a href="https://plus.google.com/101618656200865537964">Google+</a>, and <a href="https://plus.google.com/+CTimmerman">older Google+</a> now. See also my <a href="https://www.facebook.com/notes/cees-timmerman/code-snippets/156696344399918">old snippets</a> and <a href="https://userstyles.org/users/318885">user styles</a>.Cees Timmermanhttp://www.blogger.com/profile/09503128896817151851noreply@blogger.com4tag:blogger.com,1999:blog-6265571233418601933.post-61327909965098959512015-10-14T21:20:00.000+02:002015-10-15T01:50:01.086+02:00My Firefox won't paste text! A workaround using AutoHotkey.In Firefox I often find myself unable to paste into Facebook or YouTube comment boxes. I've been a Mozilla fan since 3.0, but bugs like these make Firefox a pain. Here's a workaround that works in my 64-bit Windows 7:<br />
<ol>
<li>Install <a href="http://www.autohotkey.com/">AutoHotkey</a>.</li>
<li>Save this script as "type_clipboard.ahk":
<pre>; http://www.autohotkey.com/board/topic/76296-type-out-text-in-clipboard/
; ctrl+win+v
^#v::
sendraw %clipboard%
return</pre></li>
<li>Run the script and press Ctrl+Win+V to have AutoHotkey type your clipboard text into Firefox.</li>
</ol>Cees Timmermanhttp://www.blogger.com/profile/09503128896817151851noreply@blogger.com0tag:blogger.com,1999:blog-6265571233418601933.post-34228081922104618512015-03-05T22:07:00.000+01:002019-11-07T16:44:16.578+01:00#TheDressThe dress is Coffee and Cool grey according to my new script:
<script>
"use strict" // Don't ignore duplicate keys and undeclared variables.
// Color input: http://en.wikipedia.org/wiki/List_of_colors_(compact)
// Regex: s/.*?rgb\(([^)]+)\).*?>([A-Z][^<]*)/"\2": [\1],\n/
// Sort! Colors like "Grussrel" are sneakily mentioned twice, and 5 others had different definitions.
var colors = {
"Acid green": [176,191,26],
"Aero blue": [201,255,229],
"Aero": [124,185,232],
"African violet": [178,132,190],
"Air Force blue (RAF)": [93,138,168],
"Air Force blue (USAF)": [0,48,143],
"Air superiority blue": [114,160,193],
"Alabama crimson": [175,0,42],
"Alice blue": [240,248,255],
"Alizarin crimson": [227,38,54],
"Alloy orange": [196,98,16],
"Almond": [239,222,205],
"Amaranth deep purple": [171,39,79],
"Amaranth pink": [241,156,187],
"Amaranth purple": [171,39,79],
"Amaranth red": [211,33,45],
"Amaranth": [229,43,80],
"Amazon": [59,122,87],
"Amber (SAE/ECE)": [255,126,0],
"Amber": [255,191,0],
"American rose": [255,3,62],
"Amethyst": [153,102,204],
"Android green": [164,198,57],
"Anti-flash white": [242,243,244],
"Antique brass": [205,149,117],
"Antique bronze": [102,93,30],
"Antique fuchsia": [145,92,131],
"Antique ruby": [132,27,45],
"Antique white": [250,235,215],
"Ao (English)": [0,128,0],
"Apple green": [141,182,0],
"Apricot": [251,206,177],
"Aqua": [0,255,255],
"Aquamarine": [127,255,212],
"Arctic lime": [208,255,20],
"Army green": [75,83,32],
"Arsenic": [59,68,75],
"Artichoke": [143,151,121],
"Arylide yellow": [233,214,107],
"Ash grey": [178,190,181],
"Asparagus": [135,169,107],
"Atomic tangerine": [255,153,102],
"Auburn": [165,42,42],
"Aureolin": [253,238,0],
"AuroMetalSaurus": [110,127,128],
"Avocado": [86,130,3],
"Azure (web color)": [240,255,255],
"Azure mist": [240,255,255],
"Azure": [0,127,255],
"Azureish white": [219,233,244],
"B'dazzled blue": [46,88,148],
"Baby blue eyes": [161,202,241],
"Baby blue": [137,207,240],
"Baby pink": [244,194,194],
"Baby powder": [254,254,250],
"Baker-Miller pink": [255,145,175],
"Ball blue": [33,171,205],
"Banana Mania": [250,231,181],
"Banana yellow": [255,225,53],
"Bangladesh green": [0,106,78],
"Barbie pink": [224,33,138],
"Barn red": [124,10,2],
"Battleship grey": [132,132,130],
"Bazaar": [152,119,123],
"Beau blue": [188,212,230],
"Beaver": [159,129,112],
"Beige": [245,245,220],
"Big dip o’ruby": [156,37,66],
"Bisque": [255,228,196],
"Bistre brown": [150,113,23],
"Bistre": [61,43,31],
"Bitter lemon": [202,224,13],
"Bitter lime": [191,255,0],
"Bittersweet shimmer": [191,79,81],
"Bittersweet": [254,111,94],
"Black bean": [61,12,2],
"Black leather jacket": [37,53,41],
"Black olive": [59,60,54],
"Black": [0,0,0],
"Blanched almond": [255,235,205],
"Blast-off bronze": [165,113,100],
"Bleu de France": [49,140,231],
"Blizzard Blue": [172,229,238],
"Blond": [250,240,190],
"Blue (Crayola)": [31,117,254],
"Blue (Munsell)": [0,147,175],
"Blue (NCS)": [0,135,189],
"Blue (Pantone)": [0,24,168],
"Blue (RYB)": [2,71,254],
"Blue (pigment)": [51,51,153],
"Blue Bell": [162,162,208],
"Blue Lagoon": [94,147,161],
"Blue sapphire": [18,97,128],
"Blue yonder": [80,114,167],
"Blue": [0,0,255],
"Blue-gray": [102,153,204],
"Blue-green": [13,152,186],
"Blue-magenta violet": [85,53,146],
"Blue-violet": [138,43,226],
"Blueberry": [79,134,247],
"Bluebonnet": [28,28,240],
"Blush": [222,93,131],
"Bole": [121,68,59],
"Bondi blue": [0,149,182],
"Bone": [227,218,201],
"Boston University Red": [204,0,0],
"Bottle green": [0,106,78],
"Boysenberry": [135,50,96],
"Brandeis blue": [0,112,255],
"Brass": [181,166,66],
"Brick red": [203,65,84],
"Bright cerulean": [29,172,214],
"Bright green": [102,255,0],
"Bright lavender": [191,148,228],
"Bright lilac": [216,145,239],
"Bright maroon": [195,33,72],
"Bright navy blue": [25,116,210],
"Bright pink": [255,0,127],
"Bright turquoise": [8,232,222],
"Bright ube": [209,159,232],
"Brilliant azure": [51,153,255],
"Brilliant lavender": [244,187,255],
"Brilliant rose": [255,85,163],
"Brink pink": [251,96,127],
"British racing green": [0,66,37],
"Bronze Yellow": [115,112,0],
"Bronze": [205,127,50],
"Brown (traditional)": [150,75,0],
"Brown (web)": [165,42,42],
"Brown Yellow": [204,153,102],
"Brown-nose": [107,68,35],
"Brunswick green": [27,77,62],
"Bubble gum": [255,193,204],
"Bubbles": [231,254,255],
"Bud green": [123,182,97],
"Buff": [240,220,130],
"Bulgarian rose": [72,6,7],
"Burgundy": [128,0,32],
"Burlywood": [222,184,135],
"Burnt orange": [204,85,0],
"Burnt sienna": [233,116,81],
"Burnt umber": [138,51,36],
"Byzantine": [189,51,164],
"Byzantium": [112,41,99],
"CG Blue": [0,122,165],
"CG Red": [224,60,49],
"Cadet blue": [95,158,160],
"Cadet grey": [145,163,176],
"Cadet": [83,104,114],
"Cadmium green": [0,107,60],
"Cadmium orange": [237,135,45],
"Cadmium red": [227,0,34],
"Cadmium yellow": [255,246,0],
"Café au lait": [166,123,91],
"Café noir": [75,54,33],
"Cal Poly green": [30,77,43],
"Cambridge Blue": [163,193,173],
"Camel": [193,154,107],
"Cameo pink": [239,187,204],
"Camouflage green": [120,134,107],
"Canary yellow": [255,239,0],
"Candy apple red": [255,8,0],
"Candy pink": [228,113,122],
"Capri": [0,191,255],
"Caput mortuum": [89,39,32],
"Cardinal": [196,30,58],
"Caribbean green": [0,204,153],
"Carmine (M&P)": [215,0,64],
"Carmine pink": [235,76,66],
"Carmine red": [255,0,56],
"Carmine": [150,0,24],
"Carnation pink": [255,166,201],
"Carnelian": [179,27,27],
"Carolina blue": [86,160,211],
"Carrot orange": [237,145,33],
"Castleton green": [0,86,63],
"Catalina blue": [6,42,120],
"Catawba": [112,54,66],
"Cedar Chest": [201,90,73],
"Ceil": [146,161,207],
"Celadon blue": [0,123,167],
"Celadon green": [47,132,124],
"Celadon": [172,225,175],
"Celeste": [178,255,255],
"Celestial blue": [73,151,208],
"Cerise pink": [236,59,131],
"Cerise": [222,49,99],
"Cerulean blue": [42,82,190],
"Cerulean frost": [109,155,195],
"Cerulean": [0,123,167],
"Chamoisee": [160,120,90],
"Champagne": [247,231,206],
"Charcoal": [54,69,79],
"Charleston green": [35,43,43],
"Charm pink": [230,143,172],
"Chartreuse (traditional)": [223,255,0],
"Chartreuse (web)": [127,255,0],
"Cherry blossom pink": [255,183,197],
"Cherry": [222,49,99],
"Chestnut": [149,69,53],
"China pink": [222,111,161],
"China rose": [168,81,110],
"Chinese red": [170,56,30],
"Chinese violet": [133,96,136],
"Chocolate (traditional)": [123,63,0],
"Chocolate (web)": [210,105,30],
"Chrome yellow": [255,167,0],
"Cinereous": [152,129,123],
"Cinnabar": [227,66,52],
"Cinnamon": [210,105,30],
"Citrine": [228,208,10],
"Citron": [158,169,31],
"Claret": [127,23,52],
"Classic rose": [251,204,231],
"Cobalt blue": [0,71,171],
"Cocoa brown": [210,105,30],
"Coconut": [150,90,62],
"Coffee": [111,78,55],
"Columbia blue": [196,216,226],
"Congo pink": [248,131,121],
"Cool black": [0,0,0],
"Cool grey": [140,146,172],
"Copper (Crayola)": [218,138,103],
"Copper penny": [173,111,105],
"Copper red": [203,109,81],
"Copper rose": [153,102,102],
"Copper": [184,115,51],
"Coquelicot": [255,56,0],
"Coral pink": [248,131,121],
"Coral red": [255,64,64],
"Coral": [255,127,80],
"Cordovan": [137,63,69],
"Corn": [251,236,93],
"Cornell Red": [179,27,27],
"Cornflower blue": [100,149,237],
"Cornsilk": [255,248,220],
"Cosmic latte": [255,248,231],
"Cotton candy": [255,188,217],
"Coyote brown": [129,97,60],
"Cream": [255,253,208],
"Crimson glory": [190,0,50],
"Crimson red": [153,0,0],
"Crimson": [220,20,60],
"Cyan (process)": [0,183,235],
"Cyan azure": [78,130,180],
"Cyan cobalt blue": [40,88,156],
"Cyan cornflower blue": [24,139,194],
"Cyan": [0,255,255],
"Cyan-blue azure": [70,130,191],
"Cyber grape": [88,66,124],
"Cyber yellow": [255,211,0],
"Daffodil": [255,255,49],
"Dandelion": [240,225,48],
"Dark blue": [0,0,139],
"Dark blue-gray": [102,102,153],
"Dark brown": [101,67,33],
"Dark brown-tangelo": [136,101,78],
"Dark byzantium": [93,57,84],
"Dark candy apple red": [164,0,0],
"Dark cerulean": [8,69,126],
"Dark chestnut": [152,105,96],
"Dark coral": [205,91,69],
"Dark cyan": [0,139,139],
"Dark electric blue": [83,104,120],
"Dark goldenrod": [184,134,11],
"Dark gray (X11)": [169,169,169],
"Dark green (X11)": [0,100,0],
"Dark green": [1,50,32],
"Dark imperial blue": [0,20,126],
"Dark imperial blue 2": [0,65,106],
"Dark jungle green": [26,36,33],
"Dark khaki": [189,183,107],
"Dark lava": [72,60,50],
"Dark lavender": [115,79,150],
"Dark liver (horses)": [84,61,55],
"Dark liver": [83,75,79],
"Dark magenta": [139,0,139],
"Dark medium gray": [169,169,169],
"Dark midnight blue": [0,51,102],
"Dark moss green": [74,93,35],
"Dark olive green": [85,107,47],
"Dark orange": [255,140,0],
"Dark orchid": [153,50,204],
"Dark pastel blue": [119,158,203],
"Dark pastel green": [3,192,60],
"Dark pastel purple": [150,111,214],
"Dark pastel red": [194,59,34],
"Dark pink": [231,84,128],
"Dark powder blue": [0,51,153],
"Dark puce": [79,58,60],
"Dark purple": [48,25,52],
"Dark raspberry": [135,38,87],
"Dark red": [139,0,0],
"Dark salmon": [233,150,122],
"Dark scarlet": [86,3,25],
"Dark sea green": [143,188,143],
"Dark sienna": [60,20,20],
"Dark sky blue": [140,190,214],
"Dark slate blue": [72,61,139],
"Dark slate gray": [47,79,79],
"Dark spring green": [23,114,69],
"Dark tan": [145,129,81],
"Dark tangerine": [255,168,18],
"Dark taupe": [72,60,50],
"Dark terra cotta": [204,78,92],
"Dark turquoise": [0,206,209],
"Dark vanilla": [209,190,168],
"Dark violet": [148,0,211],
"Dark yellow": [155,135,12],
"Dartmouth green": [0,112,60],
"Davy's grey": [85,85,85],
"Debian red": [215,10,83],
"Deep Green": [5,102,8],
"Deep Red": [133,1,1],
"Deep Space Sparkle": [74,100,108],
"Deep Taupe": [126,94,96],
"Deep Tuscan red": [102,66,77],
"Deep aquamarine": [64,130,109],
"Deep carmine pink": [239,48,56],
"Deep carmine": [169,32,62],
"Deep carrot orange": [233,105,44],
"Deep cerise": [218,50,135],
"Deep champagne": [250,214,165],
"Deep chestnut": [185,78,72],
"Deep coffee": [112,66,65],
"Deep fuchsia": [193,84,193],
"Deep green-cyan turquoise": [14,124,97],
"Deep jungle green": [0,75,73],
"Deep koamaru": [51,51,102],
"Deep lemon": [245,199,26],
"Deep lilac": [153,85,187],
"Deep magenta": [204,0,204],
"Deep maroon": [130,0,0],
"Deep mauve": [212,115,212],
"Deep moss green": [53,94,59],
"Deep peach": [255,203,164],
"Deep pink": [255,20,147],
"Deep puce": [169,92,104],
"Deep ruby": [132,63,91],
"Deep saffron": [255,153,51],
"Deep sky blue": [0,191,255],
"Deep spring bud": [85,107,47],
"Deep violet": [51,0,102],
"Deer": [186,135,89],
"Denim": [21,96,189],
"Desaturated cyan": [102,153,153],
"Desert sand": [237,201,175],
"Desert": [193,154,107],
"Desire": [234,60,83],
"Diamond": [185,242,255],
"Dim gray": [105,105,105],
"Dirt": [155,118,83],
"Dodger blue": [30,144,255],
"Dogwood rose": [215,24,104],
"Dollar bill": [133,187,101],
"Donkey brown": [102,76,40],
"Drab": [150,113,23],
"Duke blue": [0,0,156],
"Dust storm": [229,204,201],
"Dutch white": [239,223,187],
"Earth yellow": [225,169,95],
"Ebony": [85,93,80],
"Ecru": [194,178,128],
"Eerie black": [27,27,27],
"Eggplant": [97,64,81],
"Eggshell": [240,234,214],
"Egyptian blue": [16,52,166],
"Electric blue": [125,249,255],
"Electric crimson": [255,0,63],
"Electric cyan": [0,255,255],
"Electric green": [0,255,0],
"Electric indigo": [111,0,255],
"Electric lavender": [244,187,255],
"Electric lime": [204,255,0],
"Electric purple": [191,0,255],
"Electric ultramarine": [63,0,255],
"Electric violet": [143,0,255],
"Electric yellow": [255,255,51],
"Emerald": [80,200,120],
"Eminence": [108,48,130],
"English green": [27,77,62],
"English lavender": [180,131,149],
"English red": [171,75,82],
"English violet": [86,60,92],
"Eton blue": [150,200,162],
"Eucalyptus": [68,215,168],
"Fallow": [193,154,107],
"Falu red": [128,24,24],
"Fandango pink": [222,82,133],
"Fandango": [181,51,137],
"Fashion fuchsia": [244,0,161],
"Fawn": [229,170,112],
"Feldgrau": [77,93,83],
"Feldspar": [253,213,177],
"Fern green": [79,121,66],
"Ferrari Red": [255,40,0],
"Field drab": [108,84,30],
"Fire engine red": [206,32,41],
"Firebrick": [178,34,34],
"Flame": [226,88,34],
"Flamingo pink": [252,142,172],
"Flattery": [107,68,35],
"Flavescent": [247,233,142],
"Flax": [238,220,130],
"Flirt": [162,0,109],
"Floral white": [255,250,240],
"Fluorescent orange": [255,191,0],
"Fluorescent pink": [255,20,147],
"Fluorescent yellow": [204,255,0],
"Folly": [255,0,79],
"Forest green (traditional)": [1,68,33],
"Forest green (web)": [34,139,34],
"French beige": [166,123,91],
"French bistre": [133,109,77],
"French blue": [0,114,187],
"French fuchsia": [253,63,146],
"French lilac": [134,96,142],
"French lime": [158,253,56],
"French mauve": [212,115,212],
"French pink": [253,108,158],
"French plum": [129,20,83],
"French puce": [78,22,9],
"French raspberry": [199,44,72],
"French rose": [246,74,138],
"French sky blue": [119,181,254],
"French violet": [136,6,206],
"French wine": [172,30,68],
"Fresh Air": [166,231,255],
"Fuchsia (Crayola)": [193,84,193],
"Fuchsia pink": [255,119,255],
"Fuchsia purple": [204,57,123],
"Fuchsia rose": [199,67,117],
"Fuchsia": [255,0,255],
"Fulvous": [228,132,0],
"Fuzzy Wuzzy": [204,102,102],
"GO green": [0,171,102],
"Gamboge orange (brown)": [152,102,0],
"Gamboge": [228,155,15],
"Generic viridian": [0,127,102],
"Ghost white": [248,248,255],
"Giants orange": [254,90,29],
"Glaucous": [96,130,182],
"Glitter": [230,232,250],
"Gold (metallic)": [212,175,55],
"Gold (web) (Golden)": [255,215,0],
"Gold Fusion": [133,117,78],
"Golden brown": [153,101,21],
"Golden poppy": [252,194,0],
"Golden yellow": [255,223,0],
"Goldenrod": [218,165,32],
"Granny Smith Apple": [168,228,160],
"Grape": [111,45,168],
"Gray (HTML/CSS gray)": [128,128,128],
"Gray (X11 gray)": [190,190,190],
"Gray": [128,128,128],
"Gray-asparagus": [70,89,69],
"Gray-blue": [140,146,172],
"Green (Color Wheel) (X11 green)": [0,255,0],
"Green (Crayola)": [28,172,120],
"Green (HTML/CSS color)": [0,128,0],
"Green (Munsell)": [0,168,119],
"Green (NCS)": [0,159,107],
"Green (Pantone)": [0,173,67],
"Green (RYB)": [102,176,50],
"Green (pigment)": [0,165,80],
"Green-blue": [17,100,180],
"Green-cyan": [0,153,102],
"Green-yellow": [173,255,47],
"Grizzly": [136,88,24],
"Grullo": [169,154,134],
"Grussrel": [176,101,0],
"Gunmetal": [33,38,40],
"Guppie green": [0,255,127],
"Halayà úbe": [102,55,84],
"Han blue": [68,108,207],
"Han purple": [82,24,250],
"Hansa yellow": [233,214,107],
"Harlequin green": [70,203,24],
"Harlequin": [63,255,0],
"Harvard crimson": [201,0,22],
"Harvest gold": [218,145,0],
"Heart Gold": [128,128,0],
"Heliotrope gray": [170,152,168],
"Heliotrope magenta": [170,0,187],
"Heliotrope": [223,115,255],
"Hollywood cerise": [244,0,161],
"Honeydew": [240,255,240],
"Honolulu blue": [0,109,176],
"Hooker's green": [73,121,107],
"Hot magenta": [255,29,206],
"Hot pink": [255,105,180],
"Hunter green": [53,94,59],
"Iceberg": [113,166,210],
"Icterine": [252,247,94],
"Illuminating Emerald": [49,145,119],
"Imperial blue": [0,35,149],
"Imperial purple": [102,2,60],
"Imperial red": [237,41,57],
"Imperial": [96,47,107],
"Inchworm": [178,236,93],
"Independence": [76,81,109],
"India green": [19,136,8],
"Indian red": [205,92,92],
"Indian yellow": [227,168,87],
"Indigo (web)": [75,0,130],
"Indigo dye": [9,31,146],
"Indigo": [111,0,255],
"International Klein Blue": [0,47,167],
"International orange (Golden Gate Bridge)": [192,54,44],
"International orange (aerospace)": [255,79,0],
"International orange (engineering)": [186,22,12],
"Iris": [90,79,207],
"Irresistible": [179,68,108],
"Isabelline": [244,240,236],
"Islamic green": [0,144,0],
"Italian sky blue": [178,255,255],
"Ivory": [255,255,240],
"Jade": [0,168,107],
"Japanese carmine": [157,41,51],
"Japanese indigo": [38,67,72],
"Japanese violet": [91,50,86],
"Jasmine": [248,222,126],
"Jasper": [215,59,62],
"Jawad/Chicken Color (HTML/CSS) (Khaki)": [195,176,145],
"Jazzberry jam": [165,11,94],
"Jelly Bean": [218,97,78],
"Jet": [52,52,52],
"Jonquil": [244,202,22],
"Jordy blue": [138,185,241],
"June bud": [189,218,87],
"Jungle green": [41,171,135],
"KU Crimson": [232,0,13],
"Kelly green": [76,187,23],
"Kenyan copper": [124,28,5],
"Keppel": [58,176,158],
"Khaki (X11) (Light khaki)": [240,230,140],
"Kobe": [136,45,23],
"Kobi": [231,159,196],
"Kombu green": [53,66,48],
"La Salle Green": [8,120,48],
"Languid lavender": [214,202,221],
"Lapis lazuli": [38,97,156],
"Laser Lemon": [255,255,102],
"Laurel green": [169,186,157],
"Lava": [207,16,32],
"Lavender (floral)": [181,126,220],
"Lavender (web)": [230,230,250],
"Lavender blue": [204,204,255],
"Lavender blush": [255,240,245],
"Lavender gray": [196,195,208],
"Lavender indigo": [148,87,235],
"Lavender magenta": [238,130,238],
"Lavender mist": [230,230,250],
"Lavender pink": [251,174,210],
"Lavender purple": [150,123,182],
"Lavender rose": [251,160,227],
"Lawn green": [124,252,0],
"Lemon chiffon": [255,250,205],
"Lemon curry": [204,160,29],
"Lemon glacier": [253,255,0],
"Lemon lime": [227,255,0],
"Lemon meringue": [246,234,190],
"Lemon yellow": [255,244,79],
"Lemon": [255,247,0],
"Lenurple": [186,147,216],
"Liberty": [84,90,167],
"Licorice": [26,17,16],
"Light French beige": [200,173,127],
"Light Thulian pink": [230,143,172],
"Light apricot": [253,213,177],
"Light blue": [173,216,230],
"Light brilliant red": [254,46,46],
"Light brown": [181,101,29],
"Light carmine pink": [230,103,113],
"Light cobalt blue": [136,172,224],
"Light coral": [240,128,128],
"Light cornflower blue": [147,204,234],
"Light crimson": [245,105,145],
"Light cyan": [224,255,255],
"Light deep pink": [255,92,205],
"Light fuchsia pink": [249,132,239],
"Light goldenrod yellow": [250,250,210],
"Light gray": [211,211,211],
"Light grayish magenta": [204,153,204],
"Light green": [144,238,144],
"Light hot pink": [255,179,222],
"Light khaki": [240,230,140],
"Light medium orchid": [211,155,203],
"Light moss green": [173,223,173],
"Light orange": [255,224,192],
"Light orchid": [230,168,215],
"Light pastel purple": [177,156,217],
"Light pink": [255,182,193],
"Light red ochre": [233,116,81],
"Light salmon pink": [255,153,153],
"Light salmon": [255,160,122],
"Light sea green": [32,178,170],
"Light sky blue": [135,206,250],
"Light slate gray": [119,136,153],
"Light steel blue": [176,196,222],
"Light taupe": [179,139,109],
"Light yellow": [255,255,224],
"Lilac": [200,162,200],
"Lime (color wheel)": [191,255,0],
"Lime (web) (X11 green)": [0,255,0],
"Lime green": [50,205,50],
"Limerick": [157,194,9],
"Lincoln green": [25,89,5],
"Linen": [250,240,230],
"Lion": [193,154,107],
"Liseran Purple": [222,111,161],
"Little boy blue": [108,160,220],
"Liver (dogs)": [184,109,41],
"Liver (organ)": [108,46,31],
"Liver chestnut": [152,116,86],
"Liver": [103,76,71],
"Livid": [102,153,204],
"Lumber": [255,228,205],
"Lust": [230,32,32],
"MSU Green": [24,69,59],
"Magenta (Crayola)": [255,85,163],
"Magenta (Pantone)": [208,65,126],
"Magenta (dye)": [202,31,123],
"Magenta (process)": [255,0,144],
"Magenta haze": [159,69,118],
"Magenta": [255,0,255],
"Magenta-pink": [204,51,139],
"Magic mint": [170,240,209],
"Magnolia": [248,244,255],
"Mahogany": [192,64,0],
"Maize": [251,236,93],
"Majorelle Blue": [96,80,220],
"Malachite": [11,218,81],
"Manatee": [151,154,170],
"Mango Tango": [255,130,67],
"Mantis": [116,195,101],
"Mardi Gras": [136,0,133],
"Maroon (Crayola)": [195,33,72],
"Maroon (HTML/CSS)": [128,0,0],
"Maroon (X11)": [176,48,96],
"Mauve taupe": [145,95,109],
"Mauve": [224,176,255],
"Mauvelous": [239,152,170],
"May green": [76,145,65],
"Maya blue": [115,194,251],
"Meat brown": [229,183,59],
"Medium Persian blue": [0,103,165],
"Medium Tuscan red": [121,68,59],
"Medium aquamarine": [102,221,170],
"Medium blue": [0,0,205],
"Medium candy apple red": [226,6,44],
"Medium carmine": [175,64,53],
"Medium champagne": [243,229,171],
"Medium electric blue": [3,80,150],
"Medium jungle green": [28,53,45],
"Medium lavender magenta": [221,160,221],
"Medium orchid": [186,85,211],
"Medium purple": [147,112,219],
"Medium red-violet": [187,51,133],
"Medium ruby": [170,64,105],
"Medium sea green": [60,179,113],
"Medium sky blue": [128,218,235],
"Medium slate blue": [123,104,238],
"Medium spring bud": [201,220,135],
"Medium spring green": [0,250,154],
"Medium taupe": [103,76,71],
"Medium turquoise": [72,209,204],
"Medium vermilion": [217,96,59],
"Medium violet-red": [199,21,133],
"Mellow apricot": [248,184,120],
"Mellow yellow": [248,222,126],
"Melon": [253,188,180],
"Metallic Seaweed": [10,126,140],
"Metallic Sunburst": [156,124,56],
"Mexican pink": [228,0,124],
"Midnight blue": [25,25,112],
"Midnight green (eagle green)": [0,73,83],
"Mikado yellow": [255,196,12],
"Mindaro": [227,249,136],
"Ming": [54,116,125],
"Mint cream": [245,255,250],
"Mint green": [152,255,152],
"Mint": [62,180,137],
"Misty rose": [255,228,225],
"Moccasin": [250,235,215],
"Mode beige": [150,113,23],
"Moonstone blue": [115,169,194],
"Mordant red 19": [174,12,0],
"Moss green": [138,154,91],
"Mountain Meadow": [48,186,143],
"Mountbatten pink": [153,122,141],
"Mughal green": [48,96,48],
"Mulberry": [197,75,140],
"Mustard": [255,219,88],
"Myrtle green": [49,120,115],
"Nadeshiko pink": [246,173,198],
"Napier green": [42,128,0],
"Naples yellow": [250,218,94],
"Navajo white": [255,222,173],
"Navy purple": [148,87,235],
"Navy": [0,0,128],
"Neon Carrot": [255,163,67],
"Neon fuchsia": [254,65,100],
"Neon green": [57,255,20],
"New Car": [33,79,198],
"New York pink": [215,131,127],
"Non-photo blue": [164,221,237],
"North Texas Green": [5,144,51],
"Nyanza": [233,255,219],
"OU Crimson Red": [153,0,0],
"Ocean Boat Blue": [0,119,190],
"Ochre": [204,119,34],
"Office green": [0,128,0],
"Old burgundy": [67,48,46],
"Old gold": [207,181,59],
"Old heliotrope": [86,60,92],
"Old lace": [253,245,230],
"Old lavender": [121,104,120],
"Old mauve": [103,49,71],
"Old moss green": [134,126,54],
"Old rose": [192,128,129],
"Old silver": [132,132,130],
"Olive Drab #7": [60,52,31],
"Olive Drab (#3)": [107,142,35],
"Olive": [128,128,0],
"Olivine": [154,185,115],
"Onyx": [53,56,57],
"Opera mauve": [183,132,167],
"Orange (Crayola)": [255,117,56],
"Orange (Pantone)": [255,88,0],
"Orange (RYB)": [251,153,2],
"Orange (color wheel)": [255,127,0],
"Orange (web)": [255,165,0],
"Orange peel": [255,159,0],
"Orange-red": [255,69,0],
"Orchid pink": [242,189,205],
"Orchid": [218,112,214],
"Orioles orange": [251,79,20],
"Otter brown": [101,67,33],
"Outer Space": [65,74,76],
"Outrageous Orange": [255,110,74],
"Oxford Blue": [0,33,71],
"Pakistan green": [0,102,0],
"Palatinate blue": [39,59,226],
"Palatinate purple": [104,40,96],
"Pale aqua": [188,212,230],
"Pale blue": [175,238,238],
"Pale brown": [152,118,84],
"Pale carmine": [175,64,53],
"Pale cerulean": [155,196,226],
"Pale chestnut": [221,173,175],
"Pale copper": [218,138,103],
"Pale cornflower blue": [171,205,239],
"Pale cyan": [135,211,248],
"Pale gold": [230,190,138],
"Pale goldenrod": [238,232,170],
"Pale green": [152,251,152],
"Pale lavender": [220,208,255],
"Pale magenta": [249,132,229],
"Pale magenta-pink": [255,153,204],
"Pale pink": [250,218,221],
"Pale plum": [221,160,221],
"Pale red-violet": [219,112,147],
"Pale robin egg blue": [150,222,209],
"Pale silver": [201,192,187],
"Pale spring bud": [236,235,189],
"Pale taupe": [188,152,126],
"Pale turquoise": [175,238,238],
"Pale violet": [204,153,255],
"Pale violet-red": [219,112,147],
"Pansy purple": [120,24,74],
"Paolo Veronese green": [0,155,125],
"Papaya whip": [255,239,213],
"Paradise pink": [230,62,98],
"Paris Green": [80,200,120],
"Pastel blue": [174,198,207],
"Pastel brown": [130,105,83],
"Pastel gray": [207,207,196],
"Pastel green": [119,221,119],
"Pastel magenta": [244,154,194],
"Pastel orange": [255,179,71],
"Pastel pink": [222,165,164],
"Pastel purple": [179,158,181],
"Pastel red": [255,105,97],
"Pastel violet": [203,153,201],
"Pastel yellow": [253,253,150],
"Patriarch": [128,0,128],
"Payne's grey": [83,104,120],
"Peach puff": [255,218,185],
"Peach": [255,203,164],
"Peach 2": [255,229,180],
"Peach-orange": [255,204,153],
"Peach-yellow": [250,223,173],
"Pear": [209,226,49],
"Pearl Aqua": [136,216,192],
"Pearl": [234,224,200],
"Pearly purple": [183,104,162],
"Peridot": [230,226,0],
"Periwinkle": [204,204,255],
"Persian blue": [28,57,187],
"Persian green": [0,166,147],
"Persian indigo": [50,18,122],
"Persian orange": [217,144,88],
"Persian pink": [247,127,190],
"Persian plum": [112,28,28],
"Persian red": [204,51,51],
"Persian rose": [254,40,162],
"Persimmon": [236,88,0],
"Peru": [205,133,63],
"Phlox": [223,0,255],
"Phthalo blue": [0,15,137],
"Phthalo green": [18,53,36],
"Picton blue": [69,177,232],
"Pictorial carmine": [195,11,78],
"Piggy pink": [253,221,230],
"Pine green": [1,121,111],
"Pineapple": [86,60,13],
"Pink (Pantone)": [215,72,148],
"Pink Sherbet": [247,143,167],
"Pink lace": [255,221,244],
"Pink lavender": [216,178,209],
"Pink pearl": [231,172,207],
"Pink raspberry": [152,0,54],
"Pink": [255,192,203],
"Pink-orange": [255,153,102],
"Pistachio": [147,197,114],
"Platinum": [229,228,226],
"Plum (web)": [221,160,221],
"Plum": [142,69,133],
"Pomp and Power": [134,96,142],
"Popstar": [190,79,98],
"Portland Orange": [255,90,54],
"Powder blue": [176,224,230],
"Princeton orange": [245,128,37],
"Prune": [112,28,28],
"Prussian blue": [0,49,83],
"Psychedelic purple": [223,0,255],
"Puce red": [114,47,55],
"Puce": [204,136,153],
"Pullman Brown (UPS Brown)": [100,65,23],
"Pullman Green": [59,51,28],
"Pumpkin": [255,117,24],
"Purple (HTML)": [128,0,128],
"Purple (Munsell)": [159,0,197],
"Purple (X11)": [160,32,240],
"Purple Heart": [105,53,156],
"Purple mountain majesty": [150,120,182],
"Purple navy": [78,81,128],
"Purple pizzazz": [254,78,218],
"Purple taupe": [80,64,77],
"Purpureus": [154,78,174],
"Quartz": [81,72,79],
"Queen blue": [67,107,149],
"Queen pink": [232,204,215],
"Quinacridone magenta": [142,58,89],
"Rackley": [93,138,168],
"Radical red": [255,53,94],
"Rajah": [251,171,96],
"Raspberry glace": [145,95,109],
"Raspberry pink": [226,80,152],
"Raspberry rose": [179,68,108],
"Raspberry": [227,11,92],
"Raw umber": [130,102,68],
"Razzle dazzle rose": [255,51,204],
"Razzmatazz": [227,37,107],
"Razzmic Berry": [141,78,133],
"Rebecca Purple": [102,52,153],
"Red (Crayola)": [238,32,77],
"Red (Munsell)": [242,0,60],
"Red (NCS)": [196,2,51],
"Red (Pantone)": [237,41,57],
"Red (RYB)": [254,39,18],
"Red (pigment)": [237,28,36],
"Red devil": [134,1,17],
"Red": [255,0,0],
"Red-brown": [165,42,42],
"Red-orange": [255,83,73],
"Red-purple": [228,0,120],
"Red-violet": [199,21,133],
"Redwood": [164,90,82],
"Regalia": [82,45,128],
"Registration black": [0,0,0],
"Resolution blue": [0,35,135],
"Rhythm": [119,118,150],
"Rich black (FOGRA29)": [1,11,19],
"Rich black (FOGRA39)": [1,2,3],
"Rich black (typical)": [0,0,0],
"Rich brilliant lavender": [241,167,254],
"Rich carmine": [215,0,64],
"Rich electric blue": [8,146,208],
"Rich lavender": [167,107,207],
"Rich lilac": [182,102,210],
"Rich maroon": [176,48,96],
"Rifle green": [68,76,56],
"Roast coffee": [112,66,65],
"Robin egg blue": [0,204,204],
"Rocket metallic": [138,127,128],
"Roman silver": [131,137,150],
"Rose bonbon": [249,66,158],
"Rose ebony": [103,72,70],
"Rose gold": [183,110,121],
"Rose madder": [227,38,54],
"Rose pink": [255,102,204],
"Rose quartz": [170,152,169],
"Rose red": [194,30,86],
"Rose taupe": [144,93,93],
"Rose vale": [171,78,82],
"Rose": [255,0,127],
"Rosewood": [101,0,11],
"Rosso corsa": [212,0,0],
"Rosy brown": [188,143,143],
"Royal azure": [0,56,168],
"Royal blue": [0,35,102],
"Royal blue 2": [65,105,225],
"Royal fuchsia": [202,44,146],
"Royal purple": [120,81,169],
"Royal yellow": [250,218,94],
"Ruber": [206,70,118],
"Rubine red": [209,0,86],
"Ruby red": [155,17,30],
"Ruby": [224,17,95],
"Ruddy brown": [187,101,40],
"Ruddy pink": [225,142,150],
"Ruddy": [255,0,40],
"Rufous": [168,28,7],
"Russet": [128,70,27],
"Russian green": [103,146,103],
"Russian violet": [50,23,77],
"Rust": [183,65,14],
"Rusty red": [218,44,67],
"Sacramento State green": [0,86,63],
"Saddle brown": [139,69,19],
"Safety orange (blaze orange)": [255,103,0],
"Safety orange": [255,120,0],
"Safety yellow": [238,210,2],
"Saffron": [244,196,48],
"Sage": [188,184,138],
"Salmon pink": [255,145,164],
"Salmon": [250,128,114],
"Sand dune": [150,113,23],
"Sand": [194,178,128],
"Sandstorm": [236,213,64],
"Sandy brown": [244,164,96],
"Sandy taupe": [150,113,23],
"Sangria": [146,0,10],
"Sap green": [80,125,42],
"Sapphire blue": [0,103,165],
"Sapphire": [15,82,186],
"Satin sheen gold": [203,161,53],
"Scarlet": [253,14,53],
"Scarlet 2": [255,36,0],
"Schauss pink": [255,145,175],
"School bus yellow": [255,216,0],
"Screamin' Green": [118,255,122],
"Sea blue": [0,105,148],
"Sea green": [46,139,87],
"Seal brown": [50,20,20],
"Seashell": [255,245,238],
"Selective yellow": [255,186,0],
"Sepia": [112,66,20],
"Shadow blue": [119,139,165],
"Shadow": [138,121,93],
"Shampoo": [255,207,241],
"Shamrock green": [0,158,96],
"Sheen Green": [143,212,0],
"Shimmering Blush": [217,134,149],
"Shocking pink (Crayola)": [255,111,255],
"Shocking pink": [252,15,192],
"Sienna": [136,45,23],
"Silver Lake blue": [93,137,186],
"Silver chalice": [172,172,172],
"Silver pink": [196,174,173],
"Silver sand": [191,193,194],
"Silver": [192,192,192],
"Sinopia": [203,65,11],
"Skobeloff": [0,116,116],
"Sky blue": [135,206,235],
"Sky magenta": [207,113,175],
"Slate blue": [106,90,205],
"Slate gray": [112,128,144],
"Smalt (Dark powder blue)": [0,51,153],
"Smitten": [200,65,134],
"Smoke": [115,130,118],
"Smoky Topaz": [147,61,65],
"Smoky black": [16,12,8],
"Snow": [255,250,250],
"Soap": [206,200,239],
"Solid pink": [137,56,67],
"Sonic silver": [117,117,117],
"Space cadet": [29,41,81],
"Spanish bistre": [128,117,50],
"Spanish blue": [0,112,184],
"Spanish carmine": [209,0,71],
"Spanish crimson": [229,26,76],
"Spanish gray": [152,152,152],
"Spanish green": [0,145,80],
"Spanish orange": [232,97,0],
"Spanish pink": [247,191,190],
"Spanish red": [230,0,38],
"Spanish sky blue": [0,255,255],
"Spanish violet": [76,40,130],
"Spanish viridian": [0,127,92],
"Spartan Crimson": [158,19,22],
"Spicy mix": [139,95,77],
"Spiro Disco Ball": [15,192,252],
"Spring bud": [167,252,0],
"Spring green": [0,255,127],
"St. Patrick's blue": [35,41,122],
"Star command blue": [0,123,184],
"Steel blue": [70,130,180],
"Steel pink": [204,51,204],
"Stil de grain yellow": [250,218,94],
"Stizza": [153,0,0],
"Stormcloud": [79,102,106],
"Straw": [228,217,111],
"Strawberry": [252,90,141],
"Sunglow": [255,204,51],
"Sunray": [227,171,87],
"Sunset orange": [253,94,83],
"Sunset": [250,214,165],
"Super pink": [207,107,169],
"Tan": [210,180,140],
"Tangelo": [249,77,0],
"Tangerine yellow": [255,204,0],
"Tangerine": [242,133,0],
"Tango pink": [228,113,122],
"Taupe gray": [139,133,137],
"Taupe": [72,60,50],
"Tea green": [208,240,192],
"Tea rose (orange)": [248,131,121],
"Tea rose (rose)": [244,194,194],
"Teal blue": [54,117,136],
"Teal deer": [153,230,179],
"Teal green": [0,130,127],
"Teal": [0,128,128],
"Telemagenta": [207,52,118],
"Tenné": [205,87,0],
"Terra cotta": [226,114,91],
"Thistle": [216,191,216],
"Thulian pink": [222,111,161],
"Tickle me pink": [252,137,172],
"Tiffany Blue": [10,186,181],
"Tiger's eye": [224,141,60],
"Timberwolf": [219,215,210],
"Titanium yellow": [238,230,0],
"Tomato": [255,99,71],
"Toolbox": [116,108,192],
"Topaz": [255,200,124],
"Tractor red": [253,14,53],
"Trolley Grey": [128,128,128],
"Tropical rain forest": [0,117,94],
"True Blue": [0,115,207],
"Tufts Blue": [65,125,193],
"Tulip": [255,135,141],
"Tumbleweed": [222,170,136],
"Turkish rose": [181,114,129],
"Turquoise blue": [0,255,239],
"Turquoise green": [160,214,180],
"Turquoise": [64,224,208],
"Tuscan brown": [111,78,55],
"Tuscan red": [124,72,72],
"Tuscan tan": [166,123,91],
"Tuscan": [250,214,165],
"Tuscany": [192,153,153],
"Twilight lavender": [138,73,107],
"Tyrian purple": [102,2,60],
"UA blue": [0,51,170],
"UA red": [217,0,76],
"UCLA Blue": [83,104,149],
"UCLA Gold": [255,179,0],
"UFO Green": [60,208,112],
"UP Forest green": [1,68,33],
"UP Maroon": [123,17,19],
"USAFA blue": [0,79,152],
"USC Cardinal": [153,0,0],
"USC Gold": [255,204,0],
"Ube": [136,120,195],
"Ultra pink": [255,111,255],
"Ultra red": [252,108,133],
"Ultramarine blue": [65,102,245],
"Ultramarine": [18,10,143],
"Umber": [99,81,71],
"Unbleached silk": [255,221,202],
"United Nations blue": [91,146,229],
"University of California Gold": [183,135,39],
"University of Tennessee Orange": [247,127,0],
"Unmellow yellow": [255,255,102],
"Upsdell red": [174,32,41],
"Urobilin": [225,173,33],
"Utah Crimson": [211,0,63],
"Vanilla ice": [243,143,169],
"Vanilla": [243,229,171],
"Vegas gold": [197,179,88],
"Venetian red": [200,8,21],
"Verdigris": [67,179,174],
"Vermilion": [217,56,30],
"Vermilion 2": [227,66,52],
"Veronica": [160,32,240],
"Very light azure": [116,187,251],
"Very light blue": [102,102,255],
"Very light malachite green": [100,233,134],
"Very light tangelo": [255,176,119],
"Very pale orange": [255,223,191],
"Very pale yellow": [255,255,191],
"Violet (RYB)": [134,1,175],
"Violet (color wheel)": [127,0,255],
"Violet (web)": [238,130,238],
"Violet": [143,0,255],
"Violet-blue": [50,74,178],
"Violet-red": [247,83,148],
"Viridian green": [0,150,152],
"Viridian": [64,130,109],
"Vista blue": [124,158,217],
"Vivid amber": [204,153,0],
"Vivid auburn": [146,39,36],
"Vivid burgundy": [159,29,53],
"Vivid cerise": [218,29,129],
"Vivid cerulean": [0,170,238],
"Vivid crimson": [204,0,51],
"Vivid gamboge": [255,153,0],
"Vivid lime green": [166,214,8],
"Vivid malachite": [0,204,51],
"Vivid mulberry": [184,12,227],
"Vivid orange peel": [255,160,0],
"Vivid orange": [255,95,0],
"Vivid orchid": [204,0,255],
"Vivid raspberry": [255,0,108],
"Vivid red": [247,13,26],
"Vivid red-tangelo": [223,97,36],
"Vivid sky blue": [0,204,255],
"Vivid tangelo": [240,116,39],
"Vivid tangerine": [255,160,137],
"Vivid vermilion": [229,96,36],
"Vivid violet": [159,0,255],
"Vivid yellow": [255,227,2],
"Volt": [205,255,0],
"Warm black": [0,0,0],
"Waterspout": [164,244,249],
"Wenge": [100,84,82],
"Wheat": [245,222,179],
"White smoke": [245,245,245],
"White": [255,255,255],
"Wild Strawberry": [255,67,164],
"Wild blue yonder": [162,173,208],
"Wild orchid": [212,112,162],
"Wild watermelon": [252,108,133],
"Willpower orange": [253,88,0],
"Windsor tan": [167,85,2],
"Wine dregs": [103,49,71],
"Wine": [114,47,55],
"Wisteria": [201,160,220],
"Wood brown": [193,154,107],
"Xanadu": [115,134,120],
"Yale Blue": [15,77,146],
"Yankees blue": [28,40,65],
"Yellow (Crayola)": [252,232,131],
"Yellow (Munsell)": [239,204,0],
"Yellow (NCS)": [255,211,0],
"Yellow (Pantone)": [254,223,0],
"Yellow (RYB)": [254,254,51],
"Yellow (process)": [255,239,0],
"Yellow Orange": [255,174,66],
"Yellow rose": [255,240,0],
"Yellow": [255,255,0],
"Yellow-green": [154,205,50],
"Zaffre": [0,20,168],
"Zinnwaldite brown": [44,22,8],
"Zomp": [57,167,142]
}
function el(id){
return document.getElementById(id)
}
function name_color(){
var base = el("hex").checked ? 16 : 10
var r = parseInt(el("red").value, base)
var g = parseInt(el("green").value, base)
var b = parseInt(el("blue").value, base)
var color = get_color(r,g,b)
var rgb = colors[color]
el("result").innerHTML = "<hr style=\"height:50px;background-color:rgb("+r+","+g+","+b+")\"/>" + color + (rgb === undefined ? "" : " (#" + rgb.map(e=>('00'+e.toString(16)).slice(-2)).join("").toUpperCase() + ": " + rgb + "): <hr style=\"height:50px;background-color:rgb(" + rgb + ")\"/>")
}
function get_color(r,g,b){
var color = "Unknown"
var diff = 9000
for(var key in colors){if(!colors.hasOwnProperty(key))continue // Skip third party prototype hacks.
var c = colors[key]
var dr = Math.abs(c[0] - r)
var dg = Math.abs(c[1] - g)
var db = Math.abs(c[2] - b)
if(dr+dg+db < diff){
color = key
diff = dr+dg+db
}
}
return color
}
</script>
<h1>What's that color?</h1>
<p>Try <a href="http://xkcd.com/1492/">these context-dependent colors</a>: rgb(113,94,58) and rgb(135,154,189)</p>
<form onsubmit="return false">
R: <input id="red" type="text" value="0" size="3" maxlength="3" />
G: <input id="green" type="text" value="0" size="3" maxlength="3" />
B: <input id="blue" type="text" value="0" size="3" maxlength="3" />
<input id="hex" type="checkbox" />hex <input type="submit" value="ID color" onclick="name_color()" />
</form>
<div id="result"></div>Cees Timmermanhttp://www.blogger.com/profile/09503128896817151851noreply@blogger.com5tag:blogger.com,1999:blog-6265571233418601933.post-19884946732142760722014-11-04T19:51:00.000+01:002014-11-06T19:07:52.699+01:00Cyrillic to LatinTired of unreadable <a href="http://en.wikipedia.org/wiki/Russian_alphabet">Russian characters</a>? Try this JavaScript:
<pre>var Cyrillic_Latin = {
"А":"A", "а":"a",
"Б":"B", "б":"b",
"В":"V", "в":"v",
"Г":"G", "г":"ɡ",
"Д":"D", "д":"d",
"Е":"Je", "е":"e",
"Ё":"Jo", "ё":"jo",
"Ж":"S", "ж":"s",
"З":"Z", "з":"z",
"И":"I", "и":"i",
"Й":"J", "й":"j",
"К":"K", "к":"k",
"Л":"L", "л":"l",
"М":"M", "м":"m",
"Н":"N", "н":"n",
"О":"O", "о":"o",
"П":"P", "п":"p",
"Р":"R", "р":"r",
"С":"S", "с":"s",
"Т":"T", "т":"t",
"У":"U", "у":"u",
"Ф":"F", "ф":"f",
"Х":"X", "х":"x",
"Ц":"Ts", "ц":"ts",
"Ч":"Tj", "ч":"tj",
"Ш":"Sh", "ш":"sh",
"Щ":"Sh", "щ":"sh",
"Ъ":"", "ъ":"",
"Ы":"E", "ы":"e",
"Ь":"ʲ", "ь":"ʲ",
"Э":"E", "э":"e",
"Ю":"Ju", "ю":"ju",
"Я":"Ja", "я":"ja",
"І":"I", "і":"i",
"Ѳ":"F", "ѳ":"f",
"Ѣ":"E", "ѣ":"e",
"Ѵ":"I", "ѵ":"i",
"Ѕ":"Z", "ѕ":"z",
"Ѯ":"Ks", "ѯ":"ks",
"Ѱ":"Ps", "ѱ":"ps",
"Ѡ":"O", "ѡ":"o",
"Ѫ":"Ju", "ѫ":"ju",
"Ѧ":"Ja", "ѧ":"ja",
"Ѭ":"Ju", "ѭ":"ju",
"Ѩ":"Ja", "ѩ":"ja"
}
function Cyr2Lat(text){
var out = ""
for(i in text) out += Cyrillic_Latin[text[i]] || text[i]
return out
}
</pre>
<b>Example:</b><pre>Cyr2Lat("чем")
"tjem"
Cyr2Lat("форма")
"forma"
</pre>
<p>Here it is as a bookmarklet that converts the current page (thanks to <a href="http://stackoverflow.com/a/4399718/819417">this snippet</a>):</p>
<div class="code">javascript:(function(){function t(t){var n="";for(var i in t)n+=e[t[i]]||t[i];return n}function n(e){if(e.nodeType==3&&e.nodeValue.trim()!=""){e.nodeValue=t(e.nodeValue)}else{for(var i=e.childNodes.length-1;i>=0;--i){n(e.childNodes[i])}}}var e={"А":"A","а":"a","Б":"B","б":"b","В":"V","в":"v","Г":"G","г":"ɡ","Д":"D","д":"d","Е":"Je","е":"e","Ё":"Jo","ё":"jo","Ж":"S","ж":"s","З":"Z","з":"z","И":"I","и":"i","Й":"J","й":"j","К":"K","к":"k","Л":"L","л":"l","М":"M","м":"m","Н":"N","н":"n","О":"O","о":"o","П":"P","п":"p","Р":"R","р":"r","С":"S","с":"s","Т":"T","т":"t","У":"U","у":"u","Ф":"F","ф":"f","Х":"X","х":"x","Ц":"Ts","ц":"ts","Ч":"Tj","ч":"tj","Ш":"Sh","ш":"sh","Щ":"Sh","щ":"sh","Ъ":"","ъ":"","Ы":"E","ы":"e","Ь":"ʲ","ь":"ʲ","Э":"E","э":"e","Ю":"Ju","ю":"ju","Я":"Ja","я":"ja","І":"I","і":"i","Ѳ":"F","ѳ":"f","Ѣ":"E","ѣ":"e","Ѵ":"I","ѵ":"i","Ѕ":"Z","ѕ":"z","Ѯ":"Ks","ѯ":"ks","Ѱ":"Ps","ѱ":"ps","Ѡ":"O","ѡ":"o","Ѫ":"Ju","ѫ":"ju","Ѧ":"Ja","ѧ":"ja","Ѭ":"Ju","ѭ":"ju","Ѩ":"Ja","ѩ":"ja"};n(document)})()
</div>
Cees Timmermanhttp://www.blogger.com/profile/09503128896817151851noreply@blogger.com2tag:blogger.com,1999:blog-6265571233418601933.post-84375960393354919142014-10-03T16:33:00.000+02:002014-10-03T17:32:22.950+02:00Useful commentsWhile the comments in <a href="http://ceestimmerman.blogspot.nl/2014/06/learn-how-to-program-in-assembly-code.html">my Assembly post</a> were useful to beginners, experts who can read the code might find them annoying.
Here's an example of helpful comments for experienced programmers:
<pre><code>
function delete_month(id, index){
load_branch(id)
$(".row[id^="+id+"] .cell:nth-child("+(index+1)+")").each(function(i,e){
if(i==0 && e.className.indexOf("draggable")<0) return <span style="color:green">// only change sandbox budget.</span>
$(this).nextAll().each(function(i,e){
this.style.left = (parseInt(this.style.left)-mw)+"px"
cellBlur(this) <span style="color:green">// update availability</span>
}).addClass("changed")
$(this).prevAll().addClass("changed") <span style="color:green">// needed in case there is no next cell.</span>
$(this).remove()
})
//updateTotals() <span style="color:green">// too slow here</span>
btnSave.value = "Save*"
setBusy(0)
}
</code></pre>
Note that i'm describing <b><i>WHY</i></b> the code is there, <b>not HOW</b> it works (which should be obvious to any decent JavaScript coder, who also should have an editor capable of wrapping lines to their preferred width).Cees Timmermanhttp://www.blogger.com/profile/09503128896817151851noreply@blogger.com0tag:blogger.com,1999:blog-6265571233418601933.post-56162625659445888172014-09-10T15:31:00.000+02:002014-09-10T15:40:18.765+02:00How to freeze a Google Chrome tabChrome cares more about speed than user interaction. This simple bug just hung my tab while hogging one CPU core:
<pre><code>function isOverflowed(element){
return element.scrollHeight > element.clientHeight || element.scrollWidth > element.clientWidth;
}
function resize_to_fit(el){
var size = parseFloat(el.style.fontSize) || 55
log("resizing from " + size)
while(isOverflowed(el) && size > 8){
el.style.fontSize = size - 1
}
}
</code></pre>
Press Shift+Escape, sort by CPU descending, and end the offending process to recover. Still better than Firefox.
<br><br>
This is what i meant to write, to resize text content to fit an HTML element like a div:
<pre><code>function isOverflowed(element){
return element.scrollHeight > element.clientHeight || element.scrollWidth > element.clientWidth
}
function resizeToFit(el){
var size = parseFloat(el.style.fontSize) || 55
while(isOverflowed(el) && size > 8){
size -= 1
el.style.fontSize = size + "px"
}
}
</code></pre>Cees Timmermanhttp://www.blogger.com/profile/09503128896817151851noreply@blogger.com0tag:blogger.com,1999:blog-6265571233418601933.post-19724538235611030952014-08-26T18:20:00.000+02:002014-10-16T10:03:17.635+02:00How to manually mount a USB storage device in GNU/LinuxAfter creating a bootable (possibly smaller than 16 GB for BIOS compatibility) USB stick, using <a href="http://www.pendrivelinux.com/universal-usb-installer-easy-as-1-2-3/">Universal USB Installer</a> or <a href="http://alternativeto.net/software/universal-usb-installer/">equivalent</a>, you may find that some distros, like <a href="http://http://www.sysresccd.org/">System Rescue CD</a> do not automount your other/larger USB storage devices.
<br><br>
To solve that, run these commands from your terminal:
<pre>
mkdir stick
fdisk -l
mount <font color=red>/dev/sdc1</font> stick
</pre>
That will:
<br><br>
1. create a mountpoint<br>
2. allow you to find the device that matches your storage size, <font color=red>e.g. /dev/sdc</font><br>
3. mount the <font color=red>1</font>st partition of that device on your mountpoint
<br><br>
Before removing the device you may want to unmount it, lest OSs like Windows complain on insert:
<pre>umount stick</pre>
You can possibly <a href="http://www.linfo.org/umount.html">save keystrokes</a> by pressing the up arrow key a few times so you only have to prepend a "u" to the mount command in your command history:
<pre>umount /dev/sdc1 stick</pre>Cees Timmermanhttp://www.blogger.com/profile/09503128896817151851noreply@blogger.com0tag:blogger.com,1999:blog-6265571233418601933.post-42146320346543367212014-06-12T17:46:00.001+02:002014-06-19T10:33:17.547+02:00Learn how to program in Assembly code in 2 minutes using debug!A computer is a calculator with more features and commands to use them.<br />
<br />
To program it (tell it what to do) at the lowest human-readable level (one step above the zeroes and ones of binary), you can use Assembly code, as shown here:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<br /><object width="320" height="266" class="BLOGGER-youtube-video" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" data-thumbnail-src="https://ytimg.googleusercontent.com/vi/AH_WrG5JyEo/0.jpg"><param name="movie" value="https://youtube.googleapis.com/v/AH_WrG5JyEo&start=615&source=uds" /><param name="bgcolor" value="#FFFFFF" /><param name="allowFullScreen" value="true" /><embed width="320" height="266" src="https://youtube.googleapis.com/v/AH_WrG5JyEo&start=615&source=uds" type="application/x-shockwave-flash" allowfullscreen="true"></embed></object></div>
<br />
<br />
A neater, yet perhaps slightly more complex version of "Hello World" in Assembly can be found <a href="http://www.gnostice.com/nl_article.asp?id=225&t=The_Smallest_Hello_World_Program_At_20_Bytes">here</a>. Annotated version:
<br />
<pre class="nlpre" style="background-color: ghostwhite; border: 1px dashed rgb(217, 217, 217); font-family: Consolas, 'Liberation Mono', 'Lucida Console', 'Courier New', Courier, monospace; font-size: 13px; margin: 2.5em 0px; overflow-x: auto; padding: 10px;">A ; enter assembly mode
MOV AH,9 ; set High byte of Accumulator register to display a string of text terminated by the '$' character
MOV DX,108 ; set Data register to the location of the string to display
INT 21 ; execute an I/O function set in AH register
RET ; return
DB 'HELLO WORLD$' ; store a string
R CX ; set Counter register (switches from 16-bit mode to 32-bit mode on a 80386 CPU or better)
14 ; current code position in hexadecimal to specify program length (14 is 20 in decimal)
N MYHELLO.COM ; name your command file
W ; write the program to the file
Q ; quit debug</pre>
Sadly, Windows 2003 was the last OS that shipped with the debug command. There are other assemblers and operating systems that are free and actively supported. <a href="http://www.tutorialspoint.com/assembly_programming/">This tutorial site</a> appears to focus on the NASM assembler on Linux.
<br />
<br />
Simple assembly code runs very fast (<a href="https://www.youtube.com/watch?v=MWdG413nNkI">640x200 video on a 4.77MHz 8088 IBM PC Model 5150 with 640K RAM, SoundBlaster, and 20 MB HDD</a>), but takes a lot of work to write, and each system tends to have different opcodes, so programmers in the 1970s invented and largely moved to more abstract, higher level languages like C. In the 1990s, another such step occurred, to Java, the most business-like among new '90s languages. Lately, though, since the 2000s, high-level scripting languages like <a href="https://www.python.org/">Python</a> have become more popular among people tired of typing a lot, for code that may run milliseconds slower, <a href="http://www.toptal.com/python/why-are-there-so-many-pythons">depending on flavor.</a> Remember: First get it right, then make it fast.Cees Timmermanhttp://www.blogger.com/profile/09503128896817151851noreply@blogger.com1tag:blogger.com,1999:blog-6265571233418601933.post-3211637372082777662014-04-17T17:27:00.000+02:002014-06-25T12:49:27.286+02:00Using SharePoint 2010's REST APIGet 100 items after the first 100 items from the items of this year and month:<br />
<br />
http://site.company.tld/_vti_bin/ListData.svc/YourList?$skip=100&$top=100&$select=Year,Month,ID&$filter=Year%20eq%20%272014%27%20and%20Month%20eq%20%27Mar%27<br />
<br />
<br />
Here's a complete example in Python, TestSharePoint2010REST.py:
<pre><code>
"""
SharePoint2010 REST test app by Cees Timmerman, 24jun14.
"""
# Fix Python 2.
from __future__ import print_function
try: input = raw_input
except: pass
try: import urllib.request as urllib2
except: import urllib2
try: from ntlm3 import HTTPNtlmAuthHandler
except: from ntlm import HTTPNtlmAuthHandler
import json, re, time
web_domain = "http://subdomain.company.tld/"
user = "company\\user"
password = "secret"
passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
passman.add_password(None, web_domain, user, password)
auth_NTLM = HTTPNtlmAuthHandler.HTTPNtlmAuthHandler(passman)
opener = urllib2.build_opener(auth_NTLM)
urllib2.install_opener(opener)
url = web_domain + "_vti_bin/ListData.svc/TimeRegistration?$filter=Modified%20gt%20datetime\'2014-04-30T00:00:00.000Z\'&$orderby=Modified%20asc&$select=Id,Year,Month,Hours,Project,Resource&$top=2050"
months = "Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec".split(",")
count = 0
while 1:
print(url)
request = urllib2.Request(url)
request.add_header("accept", "application/json;odata=verbose") # The default format is application/atom+xml. Example: "accept":"application/json;odata=verbose"
response = urllib2.urlopen(request)
headers = response.info()
body = response.read().decode("utf-8")
body = re.sub(r"(?<!\\)\\'", "'", body) # Fix MicrosoftSharePointTeamServices 14.0.0.6029's incorrect JSON output. http://stackoverflow.com/questions/24390258/json-module-bug-in-python-3-4-1/24390987#comment37724338_24390290
print("Headers: {}".format(headers))
print("Body start: " + body[:800])
print("==========================\nBody end: " + body[-800:])
#err_loc=314020; print(">>>>>>Parse Error: {}<<<<<<".format(body[err_loc-40:err_loc+40])) # Debug output using value from thrown error.
j = json.loads(body)
results = j['d']['results'] if 'results' in j['d'] else j['d']
print("Len: %r" % len(results))
for item in results:
count += 1
print(item['Resource'].replace("company\\", ""), item['Project'], float(item['Hours']), "{}-{:02}-01".format(item['Year'], 1+months.index(item['Month'])), item['Id'])
print("Count: %s" % count)
# End loop or process next batch of 1000.
url = None
try: url = j['d']['__next']
except: pass
if not url: break
</code></pre>Cees Timmermanhttp://www.blogger.com/profile/09503128896817151851noreply@blogger.com0tag:blogger.com,1999:blog-6265571233418601933.post-91289010063178170782014-03-21T10:06:00.002+01:002015-03-12T19:46:17.052+01:00Patching bugs with SVNI'm using <a href="https://pypi.python.org/pypi/suds" target="_blank">Suds</a> to work with <a href="http://office.microsoft.com/en-us/sharepoint/" target="_blank">SharePoint</a>, but it was terribly slow due to <a href="http://stackoverflow.com/questions/6038226/suds-is-not-reusing-cached-wsdls-and-xsds-although-i-expect-it-to" target="_blank">broken caching</a>, so i patched it:<pre>
I:\>cd temp
I:\temp>mkdir sudssvn
I:\temp>cd sudssvn
I:\temp\sudssvn>svn co http://svn.fedorahosted.org/svn/suds/trunk
A trunk\LICENSE
A trunk\tests
A trunk\tests\rhq.py
A trunk\tests\public.py
...
I:\temp\sudssvn>"C:\Program Files (x86)\<a href="http://notepad-plus-plus.org/" target="_blank">Notepad++</a>\notepad++.exe" trunk\suds\cache.py
I:\temp\sudssvn>svn di trunk
Index: trunk/suds/cache.py
===================================================================
--- trunk/suds/cache.py (revision 712)
+++ trunk/suds/cache.py (working copy)
@@ -190,7 +190,7 @@
def put(self, id, bfr):
try:
fn = self.__fn(id)
- f = self.open(fn, 'w')
+ f = self.open(fn, 'wb')
f.write(bfr)
f.close()
return bfr
@@ -223,7 +223,7 @@
try:
fn = self.__fn(id)
self.validate(fn)
- return self.open(fn)
+ return self.open(fn, 'rb')
except:
pass
I:\temp\sudssvn>svn ci trunk
svn: E205007: Commit failed (details follow):
svn: E205007: Could not use external editor to fetch log message; consider setting the $SVN_EDITOR environment variable or using the --message (-m) or --file (-F) options
svn: E205007: None of the environment variables SVN_EDITOR, VISUAL or EDITOR are set, and no 'editor-cmd' run-time configuration option was found
I:\temp\sudssvn> ...<a href="http://tortoisesvn.net/" target="_blank">TortoiseSVN</a> GUI:
Commit
Commit failed (details follow):
Can't create directory '/svn/suds/db/transactions/712-1.txn': Permission denied
</pre>
Alas, a lack of project time/leadership stifles progress, but at least open source and free speech allows one to fork unmaintained projects. Torvalds' <a href="http://git-scm.com/" target="_blank">Git</a> (<a href="http://rogerdudler.github.io/git-guide/">simple guide</a>) was made for decentralized development like that.<br />
<br />
A <a href="http://www.google.nl/url?sa=t&rct=j&q=&esrc=s&source=web&cd=4&url=http%3A%2F%2Fwww.wandisco.com%2Fsvnforum%2Fthreads%2F40491-using-svn-client-command-line-in-xp" target="_blank">Google result</a> (and on closer inspection, previous error) tells me that instead of the GUI, i could've used the -m switch of svn:<pre>
I:\temp\sudssvn>svn ci trunk -m "fix caching on Windows"
svn: E000013: Commit failed (details follow):
svn: E000013: Can't create directory '/svn/suds/db/transactions/712-1.txn': Permission denied
</pre>
The system environment variable PATH gives me easy access to "C:\Program Files\TortoiseSVN\bin\svn.exe".Cees Timmermanhttp://www.blogger.com/profile/09503128896817151851noreply@blogger.com0tag:blogger.com,1999:blog-6265571233418601933.post-57946954662165803902014-03-01T19:02:00.000+01:002014-03-01T19:29:46.584+01:00Genderswap any webpage!After trying to read the dismal <a href="https://www.goodreads.com/book/show/26582.The_Claiming_of_Sleeping_Beauty" target="_blank"><i>The Claiming of Sleeping Beauty</i></a> again, i thought it might be interesting to see whether it'd be more palatable with reversed genders. A difficult experience. Here's the code, which you can set as a bookmark location, then click the bookmark to transform the current page:<br />
<br />
javascript:(function(){function swap(txt, a, b){return txt.split(a).join("SWPTMP").split(b).join(a).split("SWPTMP").join(b)};var subs=[[' he ',' she '],[' he\'',' she\''],['He ','She '],[' man ',' woman '],[' men',' women'],['boy','girl'],['King','Queen'],['Lord','Lady'],[' daughter',' son'],['father','mother'],['uncle','aunt'],['Prince','Princess'],[' herself',' himself'],[' her.',' him.'],[' her,',' him,'],[' her a ',' him a '],[' her an ',' him an '],[' her and ',' him and '],[' him to',' her to'],[' him up',' her up'],[' him down',' her down'],[' him again',' her again'],[' him until',' her until'],[' him w',' her w'],[' him by',' her by'],[' her ',' his '],['His ', 'Her ']];t=document.body.innerHTML;for(var i=0;i<subs.length;++i)t=swap(t, subs[i][0], subs[i][1]);document.body.innerHTML=t.replace('Princessss','Prince')})()Cees Timmermanhttp://www.blogger.com/profile/09503128896817151851noreply@blogger.com3tag:blogger.com,1999:blog-6265571233418601933.post-40598841364637505352014-02-28T14:33:00.001+01:002014-02-28T14:40:30.118+01:00T-SQL: Work Days per MonthBased on <a href="http://stackoverflow.com/a/252532/819417">http://stackoverflow.com/a/252532/819417</a><br />
<br />
ALTER FUNCTION dbo.fn_WorkDays(@StartDate DATETIME) RETURNS INT<br />
AS<br />
BEGIN<br />
IF @StartDate IS NULL<br />
RETURN NULL<br />
<br />
--Strip the time element from both dates (just to be safe) by converting to whole days and back to a date.<br />
--Usually faster than CONVERT.<br />
--0 is a date (01/01/1900 00:00:00.000)<br />
SELECT @StartDate = DATEADD(dd, DATEDIFF(dd, 0, @StartDate), 0)<br />
<br />
DECLARE @EndDate DATETIME<br />
SELECT @EndDate = dateadd(day, -1, dateadd(month, 1, @StartDate))<br />
<br />
RETURN (SELECT --Start with total number of days including weekends<br />
(DATEDIFF(dd, @StartDate, @EndDate)+1)<br />
--Subtract 2 days for each full weekend<br />
-(DATEDIFF(wk, @StartDate, @EndDate)*2)<br />
-(CASE WHEN DATEPART(dw, @StartDate) = 1 THEN 1 ELSE 0 END)<br />
-(CASE WHEN DATEPART(dw, @EndDate) = 7 THEN 1 ELSE 0 END))<br />
ENDCees Timmermanhttp://www.blogger.com/profile/09503128896817151851noreply@blogger.com0tag:blogger.com,1999:blog-6265571233418601933.post-58199934353410129002013-10-11T19:20:00.002+02:002014-02-28T14:35:31.830+01:00US Fusion Energy Lab Achieves Positive Energy ReactionIn late September, American scientists <a href="http://www.bbc.co.uk/news/science-environment-24429621" target="_blank">got more energy</a>
out of a fusion reaction than the fuel absorbed in igniting it — the
first time that’s been achieved by researchers anywhere in the world.
The research team that pulled it off is based at the National Ignition
Facility (NIF), in Livermore, California. And in a bitter twist, <a href="http://www.cbsnews.com/8301-205_162-57606588/apparent-breakthrough-in-nuclear-fusion-silenced-by-shutdown/" target="_blank">they were furloughed</a> just days afterward by the government shutdown.<br />
<a href="http://thinkprogress.org/climate/2013/10/10/2760911/american-researchers-fusion-breakthrough/">http://thinkprogress.org/climate/2013/10/10/2760911/american-researchers-fusion-breakthrough/</a><br />
<br />
<span data-ft="{"tn":"K"}" data-reactid=".r[l3wi].[1][4][1]{comment10200804301420925_4846547}.[0].{right}.[0].{left}.[0].[0].[0][3]"><span data-reactid=".r[l3wi].[1][4][1]{comment10200804301420925_4846547}.[0].{right}.[0].{left}.[0].[0].[0][3].[0]"><span data-reactid=".r[l3wi].[1][4][1]{comment10200804301420925_4846547}.[0].{right}.[0].{left}.[0].[0].[0][3].[0].[0]">Since
1953, when the fusion program started, the total spent on fusion energy
in the US, both Magnetic and Inertial is $22.4 billion dollars.
Adjusting for inflation, total fusion spending is $29.1 billion. That’s
for 57 years of fusion funding.</span> <span data-reactid=".r[l3wi].[1][4][1]{comment10200804301420925_4846547}.[0].{right}.[0].{left}.[0].[0].[0][3].[0].[3]">That’s an average of $510 million per year.</span><a class="" data-reactid=".r[l3wi].[1][4][1]{comment10200804301420925_4846547}.[0].{right}.[0].{left}.[0].[0].[0][3].[0].[4]" href="http://focusfusion.org/index.php/site/reframe/wasteful" rel="nofollow" target="_blank">http://focusfusion.org/index.php/site/reframe/wasteful</a><br data-reactid=".r[l3wi].[1][4][1]{comment10200804301420925_4846547}.[0].{right}.[0].{left}.[0].[0].[0][3].[0].[5]" /><br data-reactid=".r[l3wi].[1][4][1]{comment10200804301420925_4846547}.[0].{right}.[0].{left}.[0].[0].[0][3].[0].[6]" /><span data-reactid=".r[l3wi].[1][4][1]{comment10200804301420925_4846547}.[0].{right}.[0].{left}.[0].[0].[0][3].[0].[7]">The
U.S. federal government spent over $15 billion dollars in 2010 on the
War on Drugs, at a rate of about $500 per second. State and local
governments spent at least another 25 billion dollars.</span></span></span><br />
<span data-ft="{"tn":"K"}" data-reactid=".r[l3wi].[1][4][1]{comment10200804301420925_4846547}.[0].{right}.[0].{left}.[0].[0].[0][3]"><span data-reactid=".r[l3wi].[1][4][1]{comment10200804301420925_4846547}.[0].{right}.[0].{left}.[0].[0].[0][3].[0]"><span data-reactid=".r[l3wi].[1][4][1]{comment10200804301420925_4846547}.[0].{right}.[0].{left}.[0].[0].[0][3].[0].[7]"></span><a class="" data-reactid=".r[l3wi].[1][4][1]{comment10200804301420925_4846547}.[0].{right}.[0].{left}.[0].[0].[0][3].[0].[8]" href="http://www.drugsense.org/cms/wodclock" rel="nofollow" target="_blank">http://www.drugsense.org/cms/wodclock</a></span></span>Cees Timmermanhttp://www.blogger.com/profile/09503128896817151851noreply@blogger.com0tag:blogger.com,1999:blog-6265571233418601933.post-62613962030715316612013-10-03T15:06:00.001+02:002015-03-23T16:15:03.832+01:00IE8 is Evil.<pre><code>>>var d = {1:"one", 2:"two",}
"Expected identifier, string or number"
</code></pre>
But that works in IE9's IE8 mode!
<br><br>
Fortunately IE10 does reproduce this bug; too bad IE9 won't upgrade on this Windows 7 machine due to DLL hell. Good thing i have remote desktops:
<br>
<pre><code>>>var d = {1:"one", 2:"two"}
undefined
>>d
{...}
</code></pre>
That also works in IE8. Bug solved!
<br><br>
But wait, there's more! IE10's IE8 mode happily skips over
<br>
<pre><code>var approved_headcount = {
"ICT": {201301: 1, 201302: 2, 2013.03: 3, 201304: 1, 201305: 2, 201306: 3},
"Finance": {201301: 1, 201302: 2, 201303: 3, 201304: 1, 201305: 2, 201306: 3},
}
</code></pre>
and is thus buggy at being buggy.
<br><br>
I guess they incinerated the IE8 parser as it also returns incorrect line numbers while parsing that code block.
Cees Timmermanhttp://www.blogger.com/profile/09503128896817151851noreply@blogger.com1tag:blogger.com,1999:blog-6265571233418601933.post-86698805372513819772013-03-05T11:28:00.001+01:002013-03-05T11:28:43.178+01:00Digits to Excel column lettersA little tricky, so i'll note it here:
<pre><code>
>>> def getLetters(n):
... o = ""
... while 1:
... n, m = divmod(n-1, 26)
... o = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[m] + o
... if n < 1: break
... return o
...
>>> getLetters(1)
'A'
>>> getLetters(25)
'Y'
>>> getLetters(26)
'Z'
>>> getLetters(27)
'AA'
And i might as well include my old getCol function:
def getCol(s):
z = 0
for i in range(1, len(s) + 1):
c = s[-i]
z += ("ABCDEFGHIJKLMNOPQRSTUVWXYZ".find(c) + 1) * 26**(i - 1)
return z
</code></pre>Cees Timmermanhttp://www.blogger.com/profile/09503128896817151851noreply@blogger.com0tag:blogger.com,1999:blog-6265571233418601933.post-25941295469981124172013-01-09T12:10:00.001+01:002013-01-09T17:04:48.533+01:00Repairing slow systemsRecently my old PC became very slow at everything. I looked at the problem areas:
<br><br>
#1. CPU usage
<br><br>
Single-core machines being hogged by rude/buggy software is why i switched to a quadcore i5 for my main machine. CPU usage can be viewed and managed via your Task Manager, accessible on Windows via Ctrl+Alt+Del, Start Task Manager. If you don't want to end a rude process, you can try to lower its priority via the context menu.
<br><br>
If the CPU is automatically underclocked, perhaps dust is blocking airflow that's needed to run at full speed. When cleaning the inside of your PC, always shut off its power and stay grounded by touching the bare metal case to avoid static discharge frying your bits.
<br><br>
#2. RAM usage
<br><br>
When the temporary memory of a PC fills up, operating systems tend to use virtual memory on the hard drive, but the hard drive is orders of magnitude slower than RAM, even an SSD. Besides, writing to an SSD still shortens its lifespan more than writing to magnetic disk. Increase RAM (note the type and size your motherboard supports, and that it will match the slowest chips installed) or decrease program consumption. Note that 32-bit Windows only supports up to 4 GB of RAM and will leave the rest unused.
<br><br>
#3. Storage space
<br><br>
Many programs cache slow data to the hard disk, but when space runs out (Windows warns about this), that becomes impossible, also affecting the virtual memory. Use <a href="http://www.piriform.com/ccleaner">CCleaner</a> and <a href="http://www.uderzo.it/main_products/space_sniffer/">SpaceSniffer</a> to free up space and consider external drives for archiving. If you're ambitious, perhaps you want to try moving the entire OS to a bigger/faster disk using a boot media with disk imaging/cloning tool.
<br><br>
#4. Storage integrity
<br><br>
Environmental effects like temperature, moisture, and cosmic rays, can corrupt stored data. Modern systems can correct for this, but i've found that can produce terrible lag. Schedule regular (monthly should do) surface sector relocation scans. Ubuntu does this out of the box on startup, but Windows needs a scheduled task that runs a batch file containing <pre><code>@echo off
echo y|chkdsk c: /r
shutdown -r
</code></pre> as admin. The reboot is required because C: is probably in use.
<br><br>
I solved my old Windows XP system's lag by manually scheduling a sector repair via the C: partition's properties' extra's scan tool in Explorer.
<br><br>
S.M.A.R.T. monitoring tools like <a href="http://www.almico.com/speedfan.php">SpeedFan</a> and <a href="http://www.hdtune.com/">HD Tune</a> can indicate problems with your hard drive.
<br><br>
On a side note: Unlike many tutorials showing only easy Dell installs, i noticed that the Medion MD8818's hard disk drive is fastened by two short screws through the bottom of the tower.
<br><br>
#5. Storage order
<br><br>
Modern (file)systems are less affected by heavy read/write activity, but defragmentation every once in a while can help, except on an SSD (see also #2) as those have neglible seek/read times.
<br><br>
#6. Software updates
<br><br>
Newer software can have bugfixes and improved efficiency. Use your component manufacturer's website (like <a href="http://support.amd.com/us/gpudownload/Pages/index.aspx">AMD</a> or <a href="http://www.nvidia.com/Download/index.aspx">NVIDIA</a> for drivers) and/or reputable tool such as <a href="http://www.filehippo.com/updatechecker/">FileHippo.com Update Checker</a> (might not check drivers) and <a href="http://update.microsoft.com/">Microsoft Update</a> (doesn't check 3rd party software).
<br><br>
#7. Software alternatives
<br><br>
<a href="http://alternativeto.net/">AlternativeTo</a> lists alternatives to many bloated/slow software packages.
<br><br>Cees Timmermanhttp://www.blogger.com/profile/09503128896817151851noreply@blogger.com3tag:blogger.com,1999:blog-6265571233418601933.post-4021191521881880892012-06-28T16:54:00.000+02:002012-06-28T17:29:27.402+02:00Fixing Python 2.6+ to run Python 3 code:
<pre><code>
# -*- coding: utf-8 -*-
from __future__ import print_function
__doc__ = """XLS2DB by Cees Timmerman"""
changelog = """
2012-06-28 v1.0
"""
import glob, locale, os, re, sys, time
#from pyXLSX.xlsx import workbook # no MergedCells support and fails at Unicode.
from win32com.client import Dispatch # PyWin32 or ActivePython required. Excel, too.
#from win32com.client.gencache import EnsureDispatch as Dispatch # Also makes constants available.
#import Image # PIL to resize images.
import pymysql # Note: Python 3 doesn't support old db protocol.
print(__doc__)
print(changelog.split("\n")[-2])
print()
if sys.version[:2] == '2.':
#print("Python 2 sucks at Unicode; use Python 3 to run this.")
#sys.exit(2)
# Fix Python 2. We should be running in Python 3, though.
original_print = print
def print(*args, **kwargs):
#original_print("args: " + str(args))
#original_print("kwargs: " + str(kwargs))
new_args = []
for arg in args:
try:
new_args.append(arg.encode('ascii', errors='xmlcharrefreplace'))
except:
new_args.append(arg)
original_print(*new_args, **kwargs)
try:
input = raw_input
str = unicode
except: pass
</pre></code>Cees Timmermanhttp://www.blogger.com/profile/09503128896817151851noreply@blogger.com1tag:blogger.com,1999:blog-6265571233418601933.post-47113728542898768072012-06-21T11:57:00.000+02:002012-06-21T12:42:13.128+02:00Filtering a table using jQuery:
<pre><code>
$(document).ready(function(){
$.extend($.expr[':'], {
'containsi': function(elem, i, match, array){
return (elem.textContent || elem.innerText || '').toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0
}
})
})
function CT_filterTable(table_id, column_nr, text) {
table_id = "#"+table_id
$(table_id+" tr").hide();
$(table_id+" tr>td:nth-child("+column_nr+"):containsi('"+text.replace("'", "\\'")+"')").parent().show()
}
</code></pre>Cees Timmermanhttp://www.blogger.com/profile/09503128896817151851noreply@blogger.com1tag:blogger.com,1999:blog-6265571233418601933.post-71330279731290812292012-05-15T09:35:00.000+02:002012-05-16T10:40:47.279+02:00Installing Firefox and Flash player on Debian 6 (Squeeze)Here's what i did after installing the 180 MB CD image in a virtual machine:
<pre><code>#apt-get update
#apt-get upgrade
[ If you don't have a graphical desktop yet, try Gnome's (1.6 GB, though!): ]
# apt-get install gdm gnome-core gnome-terminal
<i># nano /etc/apt/sources.list</i>
[ Add these two for Firefox and Flash plugin: ]
deb http://packages.linuxmint.com debian import
<i>deb http://ftp.uk.debian.org/debian/ squeeze main contrib non-free</i>
# apt-get update
# apt-get remove iceweasel [ This will install the dumbed-down Epiphany browser for some reason. ]
# apt-get install firefox
<i># apt-get install flashplugin-nonfree</i></code></pre>
Maybe i should try Iceweasel (3.6.15) again as apt-get somehow installed a South African locale of Firefox (12.0). :( I fixed that by installing <a href="ftp://ftp.mozilla.org/pub/mozilla.org/firefox/releases/12.0/linux-i686/xpi/en-US.xpi">this</a> and setting general.useragent.locale to "en-US" in about:config and perhaps installing <a href="https://addons.mozilla.org/en-US/firefox/addon/quick-locale-switcher/">this</a> and/or changing the desktop shortcut to use only "firefox" instead of the opt path and %u.
<br><br>
Install and use gconf-editor to change the Nautilus desktop visible icon settings.Cees Timmermanhttp://www.blogger.com/profile/09503128896817151851noreply@blogger.com1tag:blogger.com,1999:blog-6265571233418601933.post-80716504375726628112012-03-27T15:42:00.004+02:002015-03-23T16:16:23.345+01:00Quick & easy navigation.<pre><code>String sql = "select name, address, zip, city, country, phone, url"
+ " from retailer"
+ " where latitude is not null and longitude is not null"
+ " order by pow(lat-lat2, 2) + pow(2 * min(abs(lon-lon2), 360-abs(lon-lon2)), 2) asc limit 10";
stmt = con.prepareStatement(sql);
stmt.setDouble(1, Double.parseDouble(request.getParameter("lat")));
stmt.setDouble(2, Double.parseDouble(request.getParameter("lng")));
</code></pre>
Honolulu to Los Angeles and San Fransisco in <a href="http://python.org">Python</a>:
<pre><code>>>> lat, long = (21.3069444, -157.8583333)
>>> lat2, lon2 = (34.0522342, -118.2436849)
>>> pow(lat-lat2, 2) + pow(2 * min(abs(lon-lon2), 360-abs(lon-lon2)), 2)
33839.327855007934
>>> lat2, lon2 = (37.7749295, -122.4194155)
>>> pow(lat-lat2, 2) + pow(2 * min(abs(lon-lon2), 360-abs(lon-lon2)), 2)
30952.629658700374
</code></pre>
2 * lon is ok for latitude 45 or -45, but <a href="http://stackoverflow.com/a/6549095/819417">1/cos(radians(lat))</a> is better.Cees Timmermanhttp://www.blogger.com/profile/09503128896817151851noreply@blogger.com3