Adding ‘Noto Mono’, ‘Courier New’, ‘Droid Sans Mono’, ‘Roboto Mono’, ‘Ubuntu Mono’ To Windows’ CMD

Just make sure you have those (you can google-search them or look for them at fonts.google.com, the ‘Courier New’ font-face should be already installed in your Windows).

feel free to edit/replace/add more,
make sure the fonts are mono-type, use ‘000…00’ as name.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Console\TrueTypeFont]
"000"="Noto Mono"
"0000"="Courier New"
"00000"="Droid Sans Mono"
"000000"="Roboto Mono"
"0000000"="Ubuntu Mono"

If you don’t know of name of the font (it should be exactly right!),
open any program that does some sort of font selection, and allows copy&paste, such as Microsoft-Word or even Notepad2/Notepad++.

Notepad2 has a “default font” selection, which I’m not going to actually change, but just use it to browse-for font-names.

the standard control-panel, used by most (simple) does also allow easy copy&paste.

JavaScript Ninja – Crowd Wisdom eBay Enhancements

Making eBay Buying Safer, Using Wisdom Of The Crowd.

Protect Yourself Against:
– Untrustworthy sellers
Those will accept your money but will not send you anything.
– Bad-reputation sellers
without checking out their feedbacks.
– New and inexperienced sellers
without researching their profile.

– Only trust sellers with “a lot of buyers”.
– Avoid items with overpriced shipping.
– Sort by “number of sold items” – in additional to current sorted results.
Continue reading

Hebrew Nikud, Using Unicode!

Easy copy&&paste of Hebrew letters with Nikud (extended), including the Hebrew letters
which can be useful for lack of Hebrew keyboard.

here is the real page you can play with

or visit the open-source project at https://www.github.com/eladkarako/nikud/, and report issues or suggest ideas at https://www.github.com/eladkarako/nikud/issues/

You can write using yours (or using the given letters) and add Nikud, following with copy&&paste into various applications that support Unicode, for example: whatsapp!

Enjoy!

Hebrew Unicode-Range

U+05BE,U+05C0,U+05C3,U+05C6,U+0591-U+05C7,U+05D0-U+05EA,U+05F0-U+05F4,U+FB1D-U+FB36,U+FB38-U+FB3C,U+FB3E,U+FB40-U+FB41,U+FB43-U+FB44,U+FB46-U+FB4F
U+05B0-U+05B9,U+05BB-U+05BC,U+05C1-U+05C2

Updated to latest Unicode (v9.0)
https://en.wikipedia.org/wiki/Unicode_and_HTML_for_the_Hebrew_alphabet
https://en.wikipedia.org/wiki/Hebrew_(Unicode_block)

The Unicode-range of each-letter

U+0591: HEBREW ACCENT ETNAHTA
U+0592: HEBREW ACCENT SEGOL
U+0593: HEBREW ACCENT SHALSHELET
U+0594: HEBREW ACCENT ZAQEF QATAN
U+0595: HEBREW ACCENT ZAQEF GADOL
U+0596: HEBREW ACCENT TIPEHA
U+0597: HEBREW ACCENT REVIA
U+0598: HEBREW ACCENT ZARQA
U+0599: HEBREW ACCENT PASHTA
U+059A: HEBREW ACCENT YETIV
U+059B: HEBREW ACCENT TEVIR
U+059C: HEBREW ACCENT GERESH
U+059D: HEBREW ACCENT GERESH MUQDAM
U+059E: HEBREW ACCENT GERSHAYIM
U+059F: HEBREW ACCENT QARNEY PARA

U+05A0: HEBREW ACCENT TELISHA GEDOLA
U+05A1: HEBREW ACCENT PAZER
U+05A2: HEBREW ACCENT ATNAH HAFUKH
U+05A3: HEBREW ACCENT MUNAH
U+05A4: HEBREW ACCENT MAHAPAKH
U+05A5: HEBREW ACCENT MERKHA
U+05A6: HEBREW ACCENT MERKHA KEFULA
U+05A7: HEBREW ACCENT DARGA
U+05A8: HEBREW ACCENT QADMA
U+05A9: HEBREW ACCENT TELISHA QETANA
U+05AA: HEBREW ACCENT YERAH BEN YOMO
U+05AB: HEBREW ACCENT OLE
U+05AC: HEBREW ACCENT ILUY
U+05AD: HEBREW ACCENT DEHI
U+05AE: HEBREW ACCENT ZINOR
U+05AF: HEBREW MARK MASORA CIRCLE

U+05B0: HEBREW POINT SHEVA
U+05B1: HEBREW POINT HATAF SEGOL
U+05B2: HEBREW POINT HATAF PATAH
U+05B3: HEBREW POINT HATAF QAMATS
U+05B4: HEBREW POINT HIRIQ
U+05B5: HEBREW POINT TSERE
U+05B6: HEBREW POINT SEGOL
U+05B7: HEBREW POINT PATAH
U+05B8: HEBREW POINT QAMATS
U+05B9: HEBREW POINT HOLAM
U+05BA: HEBREW POINT HOLAM HASER FOR VAV
U+05BB: HEBREW POINT QUBUTS
U+05BC: HEBREW POINT DAGESH OR MAPIQ
U+05BD: HEBREW POINT METEG
U+05BE: HEBREW PUNCTUATION MAQAF
U+05BF: HEBREW POINT RAFE

U+05C0: HEBREW PUNCTUATION PASEQ
U+05C1: HEBREW POINT SHIN DOT
U+05C2: HEBREW POINT SIN DOT
U+05C3: HEBREW PUNCTUATION SOF PASUQ
U+05C4: HEBREW MARK UPPER DOT
U+05C5: HEBREW MARK LOWER DOT
U+05C6: HEBREW PUNCTUATION NUN HAFUKHA
U+05C7: HEBREW POINT QAMATS QATAN

U+05D0: HEBREW LETTER ALEF
U+05D1: HEBREW LETTER BET
U+05D2: HEBREW LETTER GIMEL
U+05D3: HEBREW LETTER DALET
U+05D4: HEBREW LETTER HE
U+05D5: HEBREW LETTER VAV
U+05D6: HEBREW LETTER ZAYIN
U+05D7: HEBREW LETTER HET
U+05D8: HEBREW LETTER TET
U+05D9: HEBREW LETTER YOD
U+05DA: HEBREW LETTER FINAL KAF
U+05DB: HEBREW LETTER KAF
U+05DC: HEBREW LETTER LAMED
U+05DD: HEBREW LETTER FINAL MEM
U+05DE: HEBREW LETTER MEM
U+05DF: HEBREW LETTER FINAL NUN

U+05E0: HEBREW LETTER NUN
U+05E1: HEBREW LETTER SAMEKH
U+05E2: HEBREW LETTER AYIN
U+05E3: HEBREW LETTER FINAL PE
U+05E4: HEBREW LETTER PE
U+05E5: HEBREW LETTER FINAL TSADI
U+05E6: HEBREW LETTER TSADI
U+05E7: HEBREW LETTER QOF
U+05E8: HEBREW LETTER RESH
U+05E9: HEBREW LETTER SHIN
U+05EA: HEBREW LETTER TAV

U+05F0: HEBREW LIGATURE YIDDISH DOUBLE VAV
U+05F1: HEBREW LIGATURE YIDDISH VAV YOD
U+05F2: HEBREW LIGATURE YIDDISH DOUBLE YOD
U+05F3: HEBREW PUNCTUATION GERESH
U+05F4: HEBREW PUNCTUATION GERSHAYIM

A bidirectional font-faces that are Hebrew-capable:

Alef, 'SBL BibLit', 'SBL Hebrew', 'David CLM', 'Frenk Ruehl CLM', 'Hadasim CLM', Cardo, Shofar, David, 'Ezra SIL', 'Ezra SIL SR', 'Noto Sans Hebrew', FreeSerif, 'Times New Roman', FreeSans, Arial;

You can use the following snippet to load-up a font-face with spefic “by letter support” (Noto Sans, in-this case..)

/* hebrew */
@font-face {
  font-family: 'Noto Sans Hebrew';
  font-style: normal;
  font-weight: 400;
  src: local('Noto Sans Hebrew'), local('NotoSansHebrew'), url(https://fonts.gstatic.com/s/notosanshebrew/v5/QZOobcJ7ccckcnN4idgy78ymZCRHoYBsRD5MU0Qw5G8.woff2) format('woff2');
  unicode-range: U+0590-05FF, U+20AA, U+25CC, U+FB1D-FB4F;
}

*note that you might want to edit the range to match the above range, this is “as is from Google..”.

and later simply add the Noto-Sans-Hebrew in-front of the definition to every-element, it will handle exclusively just the Hebrew content, will fallback to Noto-Sans for the other latin characters whom it won’t have built-in-glyph-support.

for example:

*{ font-family: 'Noto Sans Hebrew', 'Noto Sans', sans-serif; }

Stuff You Should Exclude From Your Anti-Virus

It should be perfectly safe to exclude some folders from your anti-virus processing.
Have a look below, my notes/comments should help you understand the generic state-of mind and then you can apply the same reasoning to modify or add other items.

Continue reading

NodeJS Snippet – File Access/Modification Stat And Utimes One-Second Scope

You might get a high-precision (milliseconds) from the file-stat,
but you have to use a lower-resolution value, for utimes.

It is got to do with internal-linking to the operation-system’s libs..

but here is a nice working example for you to play-with,
essentially just reading a file’s content and last-modification/last-access times,
and rewrite the file (delete/write new one) with some altered-content,
but restoring the timestamp of the original file.

for this example to work just place a text file named file.txt, with any content, and any timestamp (you can set timestamp manually using variety of programs..), and see that the file with the new content is keeping its timestamp after-all.

/* Working With NodeJS' `utimes` and `stat`.*/
var fs      = require('fs')
   ,path    = require('path')
   ,file    = path.resolve('./file.txt')     //will work on every OS (even though it is a "Unix-slash").
   ,stat    = fs.lstatSync(file)             //preform any action on symbolic-link itself. (for example unlink, to delete a symbolic-link without following it to delete the actual file)
 //,stat    = fs.statSync(file)              //follow symbolic-link to where it points, file might be placed in another folder!
   ,content
   ;

content = fs.readFileSync(file, {encoding: "utf8"});
content = content.replace(/foo/g, "bar") + "\nSome Junk...";

fs.unlinkSync(file);
fs.writeFileSync(file, content, {encoding: "utf8"});

fs.utimesSync(file, stat.atime.getTime()/1000, stat.mtime.getTime()/1000); //will restore the access/modification time of the original-file.

/*
.atime                access time
.mtime                modification time
.birthtime || .ctime  creation time     */

You can read about this issue on:
https://github.com/nodejs/node/issues/2069#issuecomment-294596104.

CSS Snippet – The Magical Rotated Logo

Wish to place a logo that will be rotated 360-degrees back-and-forth gently on mouse-hover?

Here is your example.
right click it and select view frame’s-source to see the code behind it.

Using transition to transform the logo to rotate 360 degrees, is lovely,
but it is a one way animation-
– If you wish to keep on the movement as long the mouse-is-hovered upon the logo,
using keyframe-animation is the way to go.

right click it and select view frame’s-source to see the code behind it.

This would probably render an even higher-quality result,
since keyframe-animation uses, unambiguously, the GPU to render frames smoothly,
You can prefer the use of keyframe-animation in-favor of transition, or at-least use it in the same way, by specifying that the animation should repeat only one time.

Weirdly the ease-in-out effect, when a user no-longer hover the logo, and the animation is then rendered backward, back to the zero-position, seems to only work when using simple transition :/

Nevermind.. :]

PHP Snippet – Close Connection With A Non-Standard HTTP-Status

Send header Connection: close using <?php header('Connection: close');?> is simple enough.
When using a non-standard HTTP-status, make sure to put its definition (through header) first.

Here is the correct way of doing it:

<?php
header('HTTP/1.1 418 I\'m a teapot', true);
header("Connection: close");
?>

You’ll want to specify the HTTP-status, in-full,
in the example above I’m using the 418 I'm a teapot,
RFC2324 – Hyper Text Coffee Pot Control Protocol (HTCPCP/1.0) which, is a joke HTTP-status.

And although it is very much a real HTTP-status, you can not normally just put it at the end of header('Connection: closed', true, 418), since it will apparently won’t be parsed correctly and simply return an error 500..

So to make sure it is 100% supported, always send the HTTP-status using header, unambiguously.

Some older Apache server will probably try to gzip-compress your response,
this can be also quickly avoided by flushing the output-buffer and specifying a zero-length content:

<?php
while(ob_get_level()>0){@ob_end_flush();}
header('HTTP/1.1 418 I\'m a teapot', true);
header("Content-Encoding: none");
header("Content-Length: 0");
header("Connection: close");
?>

Actually when I’m thinking about it,
maybe you better even use HTTP 1.0 in the response,
since keep-alive is pretty much a given fact in HTTP 1.1 (unless declared otherwise).

So this might be a better way utilising it:

<?php
while(ob_get_level()>0){@ob_end_flush();}
header('HTTP/1.0 418 I\'m a teapot', true);
header("Content-Encoding: none");
header("Content-Length: 0");
header("Connection: close");
?>

Ps.
If you wish to set the HTTP version dynamically, without messing with it, just replace the correct line in the code above with this one:
header(filter_input(INPUT_SERVER, "SERVER_PROTOCOL", FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION) . ' 418 I\'m a teapot');.

Make Chrome Faster

1. Use Chrome/Chromium Of x64bit, if your machine can handle it.

2. Install those both official Chrome-extensions:
https://chrome.google.com/webstore/detail/dalkfakmooljfejnddeaibdkgbbogpea
https://chrome.google.com/webstore/detail/pcgokfnmpaefeofjpbicabmcadpcnhon

3. Access chrome://flags/ and change the following values,
you may easily reach either of those by copy&&paste them into the address-bar.

👉 chrome://flags/#num-raster-threads ➧4
👉 chrome://flags/#default-tile-width ➧1024
👉 chrome://flags/#default-tile-height ➧1024

👉 chrome://flags/#enable-fast-unload ➧Enable
👉 chrome://flags/#smooth-scrolling ➧Disable
👉 chrome://flags/#enable-quic ➧Enable
👉 chrome://flags/#enable-zero-copy ➧Enable
👉 chrome://flags/#enable-site-per-process ➧Enable
👉 chrome://flags/#v8-cache-options ➧’Cache V8 parser data.’
👉 chrome://flags/#v8-cache-strategies-for-cache-storage
➧’Aggressive’
👉 chrome://flags/#enable-scroll-anchoring ➧Disable
👉 chrome://flags/#enable-pointer-events ➧Enable
👉 chrome://flags/#passive-listener-default ➧’Force All True’
👉 chrome://flags/#document-passive-event-listeners ➧Enable
👉 chrome://flags/#passive-event-listeners-due-to-fling ➧Enable
👉 chrome://flags/#expensive-background-timer-throttling ➧Enable
👉 chrome://flags/#enable-nostate-prefetch ➧’Enabled Prerender’
👉 chrome://flags/#enable-resource-prefetch ➧’Enable Prefetching’
👉 chrome://flags/#delay-navigation ➧Disable

4. Just before the restart required in stage [3] (above),
close all other tabs (other than chrome://flags/),
access chrome://net-internals/#dns in a new-tab, and click the ‘clear host cache’, you can safely close the chrome://net-internals/#dns now, and back in the chrome://flags/ click on the big-blue ‘relaunch now’ button.

Enjoy!

HTML5 – Remove 300ms Delay On-Touch/Click – No JavaScript Required!

  1. Include a viewport tag in the <HEAD> with specific width definition.
    You may specify a minimal-one: <meta name="viewport" content="width=device-width"/>
    or a bit more complex one with initial-scale: <meta name="viewport" content="height=device-height,width=device-width,initial-scale=1.0,minimum-scale=1.0,minimal-ui"/> (you may forbid zooming/re-scale by also adding ,user-scalable=no which will slightly improve overall performances and rendering speed).
  2. Second *thing* is to instruct the page to disable double-tap gesture, it is an official technique, recommended by Mozilla/Google.

    /*`manipulation`
     * Enable panning and pinch zoom gestures, 
     * but disable additional non-standard gestures
     * such as double-tap to zoom. Disabling double-tap 
     * to zoom removes the need for browsers to delay 
     * the generation of click events
     * when the user taps the screen. This is an alias 
     * for "pan-x pan-y pinch-zoom"
     * (which, for compatibility, is itself still valid).
     */
    html{
      touch-action: pan-x pan-y pinch-zoom;
      touch-action: manipulation;
    }
    

    The above rule will be compatible with all the browsers you can think of (yes IE too), and will not require setting any onclick/ontouchstart/ontouchend/etc.. hooking events, neither halt event-bubbling.

    As always with those html-set-rules, you better put the rule-block pretty early in-your CSS-file, you you may have an option to override the touch-action rule with a different value to a specific node, a good place is probably right-after the ‘css-clear/zero code’ at the start of the file.

Java And UTF-8

java -Dfile.encoding=UTF-8

working with Windows’ console/batch file? make sure to also change the code-page using chcp:

chcp 65001
.....\java.exe -Dfile.encoding=UTF-8 .......

Continue reading

Unofficial ApkTool 🔧

Bleeding-edge builds of ApkTool.

📥 Download Version 2.2.3-118094-SNAPSHOT (11.61MB)

ApkTool uses smali and baksmali internally, and already includes them (along with few other libs).
You can the latest download links at the public maven repository: smali, baksmali, dexlib2, util, snakeyaml

– about smali: https://github.com/JesusFreke/smali

– latest smali binaries can (also) be found here: https://bitbucket.org/JesusFreke/smali/downloads/

– ApkTool’s XDA-blog-thread: https://forum.xda-developers.com/showthread.php?t=1755243

– how to build the latest ApkTool: iCompile – Build ApkTool

ExifTool – Ultimate Batch To Remove All Tags, From Infinite List Of Files, With Verbose Status And Progress Report

ExifTool is a free and open-source software program for reading, writing, and manipulating image, audio, video, and PDF metadata. It is platform independent, available as both a Perl library (Image::ExifTool) and command-line application. ExifTool is commonly incorporated into different types of digital workflows and supports many types of metadata including Exif, IPTC, XMP, JFIF, GeoTIFF, ICC Profile, Photoshop IRB, FlashPix, AFCP and ID3, as well as the manufacturer-specific metadata formats of many digital cameras.

http://www.sno.phy.queensu.ca/~phil/exiftool/
https://en.wikipedia.org/wiki/ExifTool
https://sourceforge.net/projects/exiftool/
https://downloads.sourceforge.net/project/exiftool/exiftool-10.48.zip?r=&ts=1491744058&use_mirror=netix

The following example is a batch for Windows operation-system, but it can be easily migrated to any other supported OS, to use it, just mark a bunch of files (any amount! it does not limited to usual batch-queue-limit of 9) and drag&drop them over the batch-file.

Plus it will work on any file, naturally file-types that are not supported by the ExifTool will be ignored (skipped), so feel free to just use [CTRL]+[A] to select all the files without pin-point-select just the ones you need.. or unsure if they will be supported, if it will, it will.. and if it won’t, it won’t.. :]

remove_metadata.cmd:

@echo off
:LOOP
::has argument ?
if ["%~1"]==[""] (
  echo done.
  goto END;
)
::argument exist ?
if not exist %~s1 (
  echo not exist
  goto NEXT;
)
::file exist ?
echo exist
if exist %~s1\NUL (
  echo is a directory
  goto NEXT;
)
::OK
echo is a file

set FILE_INPUT="%~s1"
set FILE_OUTPUT="%~d1%~p1%~n1_fixed%~x1"

call exiftool -progress -verbose -ignoreMinorErrors -XMPToolkit="" -all="" -trailer:all="" "%FILE_INPUT%"


:NEXT
shift
goto LOOP

:END
pause

Nice Scrollbars

Those bulky scrollbars with the useless ‘arrows’
are mostly the cause of large-font in compare to a low(er) screen-resolution.

The up/down arrows are mostly useless now-days anyway,
since it requires pin-point accuracy with the mouse,
which in most cases is not essential-
– and it is far more fun to just drag away the middle-thingy anyhow..

If you’re a page designer, HTML5 developer,
consider this minimal set of CSS3 rules to make your end result look far better:
The scrollbar will have constant dimensions, and will allow more efficient scrolling.

Continue reading

OpenSearchDescription Example

Using Wikipedia As A Generic Example.

on the main page specify the OpenSearchDescription resource like so:

<link rel="search" type="application/opensearchdescription+xml" href="/w/opensearch_desc.php" title="Wikipedia (en)"/>

Next you’ll need to serve the actual content:

<?xml version="1.0"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">
    <ShortName>Wikipedia (en)</ShortName>
    <Description>Wikipedia (en)</Description>
    <Image height="16" width="16" type="image/x-icon">https://en.wikipedia.org/static/favicon/wikipedia.ico</Image>
    <Url type="text/html" method="get" template="https://en.wikipedia.org/w/index.php?title=Special:Search&amp;search={searchTerms}" />
    <Url type="application/x-suggestions+json" method="get" template="https://en.wikipedia.org/w/api.php?action=opensearch&amp;search={searchTerms}&amp;namespace=0" />
    <Url type="application/x-suggestions+xml" method="get" template="https://en.wikipedia.org/w/api.php?action=opensearch&amp;format=xml&amp;search={searchTerms}&amp;namespace=0" />
    <moz:SearchForm>https://en.wikipedia.org/wiki/Special:Search</moz:SearchForm>
</OpenSearchDescription>

You can serve the textual-content in any way you’ll like to,
writing it dynamically using PHP or serving it from a static-file (better).

But you should serve it using the proper mimetype of application/opensearchdescription+xml
(although it is, in-fact technically a XML content, and would be probably fine to be served as text/xml too).


*People* often use PHP (Wikipedia does..) since it provides a simpler way to control the header for the content-type of the OpenSearchDescription,
which is not really an official-IANA mimetype for a file[1] [2], which means there is not a registered extension which is linked to the OpenSearchDescription mimetype,

So.. by using a simple PHP script:

<?php
  header('Content-Type: application/opensearchdescription+xml;charset=UTF-8');
  (.....echo the XML textual-content....)
?>

You’ll kind-of solve it. Badly.


If you’re running APACHE you far-better place your the XML textual-content in a Unicode/UTF-8 encoded file,
somewhere in your server, for example- at your website-root or at the same level as the index.html file.
Name it something.opensearchdescription, the file name does not actually matter.

In your .htaccess file (which should be placed on the same level, and not deeper in the folder-hirarcty, so it will be effective)-
– add the following lines:

<FilesMatch "\.(?i:opensearchdescription)$">
  <ifModule mod_headers.c>
    Header set Content-Type "application/opensearchdescription+xml;charset=UTF-8"
  </IfModule>
</FilesMatch>

You can use cURL --user-agent "Mozila/Chrome" --url "http://path-to-your-something.opensearchdescription/something.opensearchdescription" --verbose to verify the header does come-back as part of the response-headers.


Files with that extension will be served with this Content-Type header.

Done, Enjoy :]

Preload Google Analytics

Adding a small addition to the head of the page will speed-up the loading of the Google Analytics code you most-probably have on your page.

And it is super easy too!
for the most parts you only need to add a single line:
Continue reading

aria2c Sample – Chromium Command-Line Switch Updater

Getting the most updated command-line switches for Chromium (Google-Chrome base code) is always a work in progress,
since this is a `live code` you can never say “Ok, I’m Done”, there will always be a new one, or old one retired from being actively used in the, well.., actual code.
So if you’re relaying on command-line switches in your scripts, or just want to try out new features before the `bleed into` the actual Google-Chrome main version, you probably want to bookmark this article :]]

Continue reading

AdBlock Rule To Block Ping And Beacon Requests

*$important,beacon

Compatible with every adblocking plugins, that supports the adblock-rule format.

You probably want to uninstall AdBlock and install uBlock Origin. AdBlock had sold out :/

JavaScript Snippet – A Human-Readable Memory-Formatter, Add Commas To A Number By Regular-Expression

function human_readable_bytes_size(bytes, decimals, sap) {
  decimals = "number" === typeof decimals ? decimals : 2;
  sap = "string" === typeof sap ? sap : "";

  var 
    size = ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
  , factor = Math.floor(  (String(bytes).length - 1) / 3  )
  ;
  
  bytes = bytes / Math.pow(1024, factor);  //calc
  bytes = Math.floor(bytes * Math.pow(10, decimals)) / Math.pow(10, decimals);  //round digits
  
   
  return String(bytes) + sap + size[factor];
}



human_readable_bytes_size(29)
//"29B"
human_readable_bytes_size(29000000000000000)
//"25.75PB"
human_readable_bytes_size(2900000000000)
//"2.63TB"
human_readable_bytes_size(290000000000)
//"270.08GB"
human_readable_bytes_size(290000000000,5)
//"270.08354GB"
human_readable_bytes_size(290000000000,5,"---")
//"270.08354---GB"

also available on GitHub: https://github.com/eladkarako/javascript_human_readable_bytes_size

Would you like the PHP version? – http://icompile.eladkarako.com/php-snippet-a-human-readable-memory-formatter-add-commas-to-a-number-by-regular-expression/


This is a variation with comma-separation (only for the integer part since the fraction part looks weird w/ commas..)

function human_readable_bytes_size(bytes, digits, sap, is_comma_sap) {  "use strict";
  digits       = "number"  === typeof digits        ? digits         :  2;
  sap          = "string"  === typeof sap           ? sap            : "";
  is_comma_sap = "boolean" === typeof is_comma_sap  ? is_comma_sap   : false;

  var  size = ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
     , factor = Math.floor(  (String(bytes).length - 1) / 3  )
     ;

  bytes = bytes / Math.pow(1024, factor);  //calc
  bytes = Math.floor(bytes * Math.pow(10, digits)) / Math.pow(10, digits);  //round digits
  
  if(true === is_comma_sap){
    bytes = String(bytes).split(".");
    bytes[0] = bytes[0].replace(/(\d)(?=(\d{3})+$)/g, "$1,");
    bytes = bytes.join(".");
  }

  return String(bytes) + sap + size[factor];
}

since it is very rare (actually improbable) to use the comma-feature when measuring to the largest scale available,
– In my project https://github.com/eladkarako/any2base64 I’m using a slightly different variation that actually ‘reduce a scale by one’ meaning, instead of using 1GB it will use 1024MB (or 1000-MiB..
* [1] [2])

It works nicely, and sometimes helps to comprehend byte sizes more clearly… Ahhh.. human perspective! ;] ;]

Mozilla FTP – Download Latest Firefox

Latest (~sort of~ “nightly”) Firefox Developer Edition, Code-Name `Aurora`
https://ftp.mozilla.org/pub/firefox/nightly/latest-mozilla-aurora/

This is the full offline-installer, not the `installer-stub` you get from the official website.


Latest Nightly-Build from trunk Firefox
https://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central/

You can download a localised (or “localized”.. if you’re an American..) language-specific version on https://ftp.mozilla.org/pub/firefox/nightly/latest-mozilla-aurora-l10n/.


Latest Beta
https://ftp.mozilla.org/pub/firefox/nightly/latest-mozilla-beta-l10n/

It seems that there is no generic package so you must choose one of the localised-packages,
for example https://ftp.mozilla.org/pub/firefox/nightly/latest-mozilla-beta-l10n/firefox-47.0.en-GB.win64.installer.exe or https://ftp.mozilla.org/pub/firefox/nightly/latest-mozilla-beta-l10n/firefox-47.0.en-GB.win64.zip


You may also download ESR (extended support release) for latest or not-so latest versions of Firefox, which is mostly useful if you don’t want to keep updating the core-browser’s version a lot..
Version 45: https://ftp.mozilla.org/pub/firefox/nightly/latest-mozilla-esr45-l10n/
And version 52: https://ftp.mozilla.org/pub/firefox/nightly/latest-mozilla-esr52-l10n/

Here too, you must choose a localised-download..


Browser https://ftp.mozilla.org/pub/firefox/nightly/ for “by date” downloads or any other variation of Firefox you may download, in-full.

HTML Snippet – 100% Fill Textarea-Page

The base of numerous of custom HTML-components
and functional pages is a “textarea page” which consist of
a (surprise surprise..) <textarea> element
and some sort of functionality integrated by a form-submit, JavaScript,
or a mix of both.

Continue reading

Delete A Lot Of WordPress Tags

No Need To Directly Access The DB Or Execute Any SQL Commands (Although It Would Be A Lot Faster…)

Edit a post, open the developer-panel,
switch to “console” and execute this code to delete 15 tags at once.. ;)

Really just a dirty dirty way :))

var x = document.querySelectorAll('.tagchecklist .ntdelbutton');
x[0].focus();  x[0].click();
x[1].focus();  x[1].click();
x[2].focus();  x[2].click();
x[3].focus();  x[3].click();
x[4].focus();  x[4].click();
x[5].focus();  x[5].click();
x[6].focus();  x[6].click();
x[7].focus();  x[7].click();
x[8].focus();  x[8].click();
x[9].focus();  x[9].click();
x[10].focus(); x[10].click();
x[11].focus(); x[11].click();
x[12].focus(); x[12].click();
x[13].focus(); x[13].click();
x[14].focus(); x[14].click();
x[15].focus(); x[15].click();

Deleting them all is kind-of weird: since querying for elements and “deleting” the current element actively changes the list of elements,
we can use the initial query to count roughly how much element were left, looping and querying the first element and removing it –
– keeping querying and removing a single element while the main loop “just checks if there are any still existing”.
– it will take just few minutes for couple of hundreds of tags, and the window might hang for a bit (don’t kill it.. just keep on waiting :/)
and at the end of the run you’ll have 100% post :]

here is it.. plus an alternative for the click method before.

function emu_click_new(target){
  if("object" !== typeof target) return;
  target.dispatchEvent(
    new MouseEvent("click", { screenX:    0     /*MouseEvent  [https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/MouseEvent] */
                            , screenY:    0
                            , clientX:    0
                            , clientY:    0
                            , ctrlKey:    false
                            , shiftKey:   false
                            , altKey:     false
                            , metaKey:    false
                            , button:     0     /*left button       */
                            , buttons:    0     /*no sticky press   */
                            , view:       self  /*UIEventInit [https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/UIEvent]       */
                            , bubbles:    true  /*EventInit   [https://developer.mozilla.org/en-US/docs/Web/API/Event/Event]           */
                            , cancelable: true
                            , scoped:     false
                            , composed:   false
                            }
                  )
  );
}

document.querySelectorAll('.tagchecklist .ntdelbutton').forEach(function(e){
  setTimeout(function(){
    e = document.querySelector('.tagchecklist .ntdelbutton');
    emu_click_new(e);
  }, 100);
});

.htaccess CORS

Header unset Access-Control-Allow-Methods
Header unset Access-Control-Allow-Origin
Header unset Access-Control-Allow-Headers
Header unset Access-Control-Expose-Headers
Header unset Access-Control-Allow-Credentials
Header unset Timing-Allow-Origin

Header set Access-Control-Allow-Methods      "CONNECT,GET,HEAD,OPTIONS,PING,POST,TRACE"
Header set Access-Control-Allow-Origin       "*"
Header set Access-Control-Allow-Headers      "Accept,Accept-Charset,Accept-Encoding,Accept-Language,Access-Control-Allow-Credentials,Access-Control-Allow-Headers,Access-Control-Allow-Methods,Access-Control-Allow-Origin,Access-Control-Expose-Headers,Access-Control-Max-Age,Access-Control-Request-Headers,Access-Control-Request-Method,Cache-Control,Connection,Content-Description,Content-Encoding,Content-Language,Content-Length,Content-Transfer-Encoding,Content-Type,Cookie,Date,DNT,Expires,Host,If-Modified-Since,Keep-Alive,Last-Modified,Origin,Pragma,Referer,Remote-Address,Server,Set-Cookie,Timing-Allow-Origin,Transfer-Encoding,User-Agent,Vary,X-Content-Type-Options,X-CustomHeader,X-Forwarded-For,X-Forwarded-Host,X-Forwarded-Port,X-Forwarded-Proto,X-Forwarded-Server,X-HTTP-Method-Override,X-Modified,X-OTHER,X-PING,X-PINGOTHER,X-Powered-By,X-Real-IP,X-Requested-With"
Header set Access-Control-Expose-Headers     "Accept,Accept-Charset,Accept-Encoding,Accept-Language,Access-Control-Allow-Credentials,Access-Control-Allow-Headers,Access-Control-Allow-Methods,Access-Control-Allow-Origin,Access-Control-Expose-Headers,Access-Control-Max-Age,Access-Control-Request-Headers,Access-Control-Request-Method,Cache-Control,Connection,Content-Description,Content-Encoding,Content-Language,Content-Length,Content-Transfer-Encoding,Content-Type,Cookie,Date,DNT,Expires,Host,If-Modified-Since,Keep-Alive,Last-Modified,Origin,Pragma,Referer,Remote-Address,Server,Set-Cookie,Timing-Allow-Origin,Transfer-Encoding,User-Agent,Vary,X-Content-Type-Options,X-CustomHeader,X-Forwarded-For,X-Forwarded-Host,X-Forwarded-Port,X-Forwarded-Proto,X-Forwarded-Server,X-HTTP-Method-Override,X-Modified,X-OTHER,X-PING,X-PINGOTHER,X-Powered-By,X-Real-IP,X-Requested-With"
Header set Access-Control-Allow-Credentials  "true"
Header set Timing-Allow-Origin               "*"

eBay Bad Sellers

There are plenty of “Bad-Buyers” websites,
for sellers to be adding to their “ignore list”,
but not much of (if any) “bad seller” lists,


From time to time you hear of a seller that sends partial-delivery,
Or even avoid sending anything at all (especially if you place a very small order),
After two or three months when you’ll send them a message,
They will act *all “surprised”* and if you are lucky you might get your money back,
that is, if they will bothered to answer you at all,
and it wasn’t too long until you’ve opened a case with either eBay/PayPal.

why wouldn’t you just avoid that scenario at all?
apparently my other article JavaScript Ninja – Crowd Wisdom eBay Enhancements was so popular, that I’ve actually got address by few of my blog-readers,
sharing some ‘horror’-stories about recent purchases,
We’ve had a new idea:

A seller blacklist

Continue reading

CSS3 Ninja – Pure CSS-KeyFrame Animation Example

An infinite, alternate animation converting a shape, with initial delay,
no javascript, pure css.

– centring the shape using the top0-left0-right0-bottom0-margin_auto trick.
– sizing the share using viewport

vw: 1/100th viewport width
vh: 1/100th viewport height
vmin: 1/100th of the smallest side
vmax: 1/100th of the largest side

HTML Entity – Infinite Convertion Bookmarklet Toolkit

javascript:(function(window, document, to_HTMLENTITY, s, is_everychar){  "use strict";
  while(true){
    s             = prompt("String To HTML-Entity.\nEnter Input String:", s);
    if(null === s) return;
    is_everychar  = prompt("String To HTML-Entity.\n[true] Convert Every Character.\n[false]Convert Just Unicode.", "false");

    prompt("HTML-Entity Result:", to_HTMLENTITY(s, "true" === is_everychar));
  }
}(
  top
, top.document
, function to_HTMLENTITY(s, is_everychar){
    var regex = true === is_everychar ? /./ug : /[\u0080-\u10FFFF]/ug
    return s.replace(regex, function(c){
      c = c.charCodeAt(0).toString(16).toUpperCase();
      c = ("0000" + c).substr(-4);
      c = "&#x" + c + ";";
      return c;
    });
  }
, ""
));

minified..

javascript:(function(window,document,to_HTMLENTITY,s,is_everychar){while(true){s=prompt("String To HTML-Entity.\nEnter Input String:",s);if(null===s)return;is_everychar=prompt("String To HTML-Entity.\n[true] Convert Every Character.\n[false]Convert Just Unicode.","false");prompt("HTML-Entity Result:",to_HTMLENTITY(s,"true"===is_everychar))}})(top,top.document,function to_HTMLENTITY(s,is_everychar){var regex=true===is_everychar?/./ug:/[\u0080-\u10FFFF]/ug;return s.replace(regex,function(c){c=c.charCodeAt(0).toString(16).toUpperCase();
c=("0000"+c).substr(-4);c="&#x"+c+";";return c})},"");

HTML ENTITY – Every Character VS. Just Unicode

function to_HTMLENTITY(s, is_everychar){ "use strict";
  var regex = true === is_everychar ? /./ug : /[\u0080-\u10FFFF]/ug
  return s.replace(regex, function(c){
    c = c.charCodeAt(0).toString(16).toUpperCase();
    c = ("0000" + c).substr(-4);
    c = "&#x" + c + ";";
    return c;
  });
}

HTML Entity – Unicode Escape

For Unicode only:

'Français'
  .replace(/[\u0080-\u10FFFF]/ug, function(c){
                                    return "&#x" + ("0000" + c.charCodeAt(0).toString(16)).toUpperCase().substr(-4) + ";" 
                                  });

output:

&#x0046;ran&#x00E7;ais

Continue reading

Google Domain2IP (DNS Over HTTPS)

https://dns.google.com/resolve?name=example.com

Will give you:

{"Status": 0,"TC": false,"RD": true,"RA": true,"AD": true,"CD": false,"Question":[ {"name": "example.com.","type": 1}],"Answer":[ {"name": "example.com.","type": 1,"TTL": 36524,"data": "93.184.216.34"}]}

You can see more switches at this version:
https://dns.google.com/query?name=example&type=A&dnssec=true

Read more:
https://developers.google.com/speed/public-dns/docs/dns-over-https

The Most Popular Adblock Lists

Adblock Warning Removal List                   https://easylist-downloads.adblockplus.org/antiadblockfilters.txt
Anti-Adblock Killer by Reek                    https://raw.githubusercontent.com/reek/anti-adblock-killer/master/anti-adblock-killer-filters.txt
Blockzilla by zpacman                          https://raw.githubusercontent.com/zpacman/Blockzilla/master/Blockzilla.txt
EasyList                                       https://easylist.to/easylist/easylist.txt
EasyList Arabian                               https://easylist-downloads.adblockplus.org/Liste_AR.txt
EasyList Bulgarian                             http://stanev.org/abp/adblock_bg.txt
EasyList Chinese                               https://easylist-downloads.adblockplus.org/easylistchina.txt
EasyList Chinese CJX's Annoyance List          https://raw.githubusercontent.com/cjx82630/cjxlist/master/cjx-annoyance.txt
Easylist Czech/Slovak                          https://raw.githubusercontent.com/tomasko126/easylistczechandslovak/master/filters.txt
EasyList Dutch                                 https://easylist-downloads.adblockplus.org/easylistdutch.txt
EasyList French                                https://easylist-downloads.adblockplus.org/liste_fr.txt
EasyList Germany                               https://easylist.to/easylistgermany/easylistgermany.txt
EasyList Hebrew                                https://raw.githubusercontent.com/easylist/EasyListHebrew/master/EasyListHebrew.txt
EasyList Icelandic                             https://adblock.gardar.net/is.abp.txt
EasyList Indonesian                            https://raw.githubusercontent.com/heradhis/indonesianadblockrules/master/subscriptions/abpindo.txt
EasyList Italian                               https://easylist-downloads.adblockplus.org/easylistitaly.txt
EasyList Japanese                              https://raw.githubusercontent.com/k2jp/abp-japanese-filters/master/abp_jp.txt
Easylist Latvian                               https://notabug.org/latvian-list/adblock-latvian/raw/master/lists/latvian-list.txt
EasyList Lithuanian                            http://margevicius.lt/easylistlithuania.txt
EasyList Romanian                              https://www.zoso.ro/pages/rolist.txt
EasyList Russian                               https://easylist-downloads.adblockplus.org/advblock.txt
EasyList Spanish                               https://easylist-downloads.adblockplus.org/easylistspanish.txt
EasyList without element hiding rules          https://easylist-downloads.adblockplus.org/easylist_noelemhide.txt
EasyPrivacy                                    https://easylist.to/easylist/easyprivacy.txt
EasyPrivacy without international filters      https://easylist-downloads.adblockplus.org/easyprivacy_nointernational.txt
Fanboy's Annoyance List                        https://easylist.to/easylist/fanboy-annoyance.txt
Fanboy's Social Blocking List                  https://easylist.to/easylist/fanboy-social.txt
I don't care about cookies                     https://www.kiboke-studio.hr/i-dont-care-about-cookies/abp/
Prebake - Filter Obtrusive Cookie Notices      https://raw.githubusercontent.com/liamja/Prebake/master/obtrusive.txt

ImageMagick Nightly Builds

https://www.imagemagick.org/download/binaries/?C=M;O=D

Sadly there is no “latest” entry,
but you can sort by modification date,
(and even parse a digest.rdf to find-out the name of the latest build..)

and make-use of your browser’s [CTRL]+[F] to look for your prefered build,
for me it is the Windows x64 fully static, portable Q16, the higher version (ver 7 given the choice between latest build of 6 or 7..).

Tips:
– use multi-part download manager if you want to download with speed-rates greater than 80KB/S
– use http instead of https prefix to avoid the ssl hand-shake and download faster on download-managers such as OrbitDownloader :)
– you can find Android compatible builds if you want to give your mobile-phone the power of the gods… :))


It is a bit messy to find the correct download since it does not separated properly,
but you may run the following line in the developer’s-panel’s console:
document.querySelectorAll('[href*="portable"]:not([href$="asc"])').forEach(function(element){ console.log(element.href); })

to get just the useful ones:
For Windows x64 (64-bit):
https://www.imagemagick.org/download/binaries/ImageMagick-7.0.4-5-portable-Q16-x64.zip
https://www.imagemagick.org/download/binaries/ImageMagick-6.9.7-5-portable-Q16-x64.zip

For Windows x86 (32-bit):
https://www.imagemagick.org/download/binaries/ImageMagick-7.0.4-5-portable-Q16-x86.zip
https://www.imagemagick.org/download/binaries/ImageMagick-6.9.7-5-portable-Q16-x86.zip

JavaScript Ninja – document.write Alternative

If you use document.write to write an entire new document,
Chrome might apply a security-policy, warning or even blocking every internal-script you have.

As an alternative, only use document.write to write the doctype,
and set the HTML-source using document.documentElement.innerHTML = ".......".

Here is a working code you, that should be loaded after the document has ready but before it rendered (a.k.a DOMContentLoaded or at_document_end if you are doing this in Chrome’s extension).

Continue reading

Chrome Extension Snippet – Modify Response Header

If you would like to ‘fake give yourself CORS’ for every request, modify cookies to remove the ‘http’ only directive so you could always edit cookies using javascript, or perhaps just add an X-Hello: World header to every response you get from anywhere, to fool your browser to think it is the real thing, got from a foo-server,
– here is what you need to do:
Continue reading

FFMPEG – Pre-Fill File Duration Into FFMPEG’s MP3-Concatenation File-List, Using FFPROBE

This is will generate a text file filed with all the mp3 files in the folder,
it will also PRE QUERY each file using FFPROBE and will add the result to the file,
helping to avoid sync-or-duration problems.

ffprobe supports built-in formatting, which might help you avoid using external commands such as cut, sed, grep, etc… .

Continue reading

JSON.stringify With Escape For Unicode-Characters

You may be familiar with PHP’s json_encode which allows you to do wonderful things such as giving you a ASCII safe version of Unicode-content (which is the default, and if you actually do want to return a plain Unicode content you need to specify JSON_UNESCAPED_UNICODE flag).

In your browser (or NodeJS in that matter..) JSON.stringify do not include a built-in parser for you to use, but it DOES include an option to specify a “replacer” function, which acts as the parser, naturally there is a lot more free-ground to play around, but if the only thing you need is something similar to PHP’s json_encode read ahead..

A nifty little trick I’m going to use next is a regular-expression replacing using Unicode values of all characters with code above 160 (decimal) to the maximum value for a single Unicode-character which is 65535.
Although we can tolerate character-values of up until 255, those above 160 are generally not-considered ASCII safe, and includes special control-characters and language-directional control which might break the text-stream.

Continue reading

Aria2C Example Download Script To Download Latest FFMPEG

aria2c https://aria2.github.io/ is a console-multi-part download manager, very similar to cURL or wGET. It also allow you to download a single file, using multiple-partial segments, downloading the whole thing much faster (assuming the host isn’t limiting download speed by IP, or block multipart downloads).

It also allows you to download same file from different hosts (for example a Ubuntu ISO, from few mirrors), or, simply multiple-files, from same and or different hosts with the additional of using http-pipeline to save on bandwidth, there are more stuff..

The multipart-download, may replace download-managers such as FlashGet, OrbitDownloader or (in some cases) jDownloader, mostly because it is simply script’able, you can even launch “callbacks” on several pin-points in download timeline.

I use it in plain Windows-CMD batch file, to download the latest FFMPEG from https://ffmpeg.zeranoe.com/builds/, including an unzip action at the end and moving some of the core-files.

There is an optional log.txt file creating, which may be useful for debug..
pre-locating using falloc is mostly for NTFS (not FAT32!) and newer file-OS,
You may download aria2c, and run it with --help for all of the other switches..

Continue reading