Skip to content


Node.js / npm mini cheatsheet

Just some really basic commands, but paradoxically they’re not always obvious to find so hopefully they’ll help some newcomers

Running a script with Node.js:
node myscript.js

Initializing a Node app/package:
Move to the target folder (where you want to place your code) and npm init

Installing dependencies (listed in package.json) for the current package:
npm install

Updating dependencies:
1) Quick and dirty: edit package.json and replace version numbers for the dependencies you want to update with "*", then run
npm install --save, or npm install --save-dev for the devDependencies
2) Normal way: for each package, one by one, run:
npm install package-name --save (or --save-dev)
It happened to me in the past that dependencies wouldn’t update when I ran that, in which case you can try to change their version number as described in 1), only one by one, and you could also try deleting your package-lock.json file
3) npm update is also supposed to update dependencies, in the same way as 1) I remember it failing more often than succeeding, but last time I tried it worked nicely

Removing some dependencies:
Remove their entries from package.json, then run npm prune

Updating global librairies/packages:
npm update -g

Removing a global package:
npm uninstall -g [package name]

Sources:
https://www.themarketingtechnologist.co/how-to-update-an-out-of-date-package-json/
http://www.kubilayerdogan.net/node-js-1-initialize-a-node-js-project-with-dependencies/

Posted in JavaScript / TypeScript / Node.js.


How to download an old version of a freesite on Freenet

I just dug up that 2+ year old draft so this will be short.
Freenet-hosted websites (“freesites”) are usually advertised via a “USK@…” URI, which allows you to fetch the latest version automatically. But when a freesite is updated, actually the old one remains in the system (at least, as long as it hasn’t decayed yet). It’s possible to access any old revision (again, as long as it hasn’t been flushed) via a simple URL manipulation:

For instance, the current version of FMS is accessible via this key:
USK@0npnMrqZNKRCRoGojZV93UNHCMN-6UU3rRSAmP6jNLE,~BG-edFtdCC1cSH4O3BWdeIYa8Sw5DfyrSV-TKdO5ec,AQACAAE/fms/142/

And a specific old version would be accessed via this key:
SSK@0npnMrqZNKRCRoGojZV93UNHCMN-6UU3rRSAmP6jNLE,~BG-edFtdCC1cSH4O3BWdeIYa8Sw5DfyrSV-TKdO5ec,AQACAAE/fms-140/

The starting “USK” is replaced by “SSK”, and the end of the URI changes from [sitename]/[version]/ to [sitename]-[version]/

This used to be explained on the Freenet wiki there wiki.freenetproject.org/USK, but apparently this page was removed in the migration :/

Posted in software.


Windows duplicates (and keeps) your installers (and NVIDIA does it too)

Today, I decided to do some computer cleaning, and I thought I’d search and destroy some large-ish duplicate files. Since I had forgotten what was my usual duplicate finding software, I found that old one called simply “Duplicate Files Finder“, which is open source and still working nicely and at least doesn’t weigh a ton like most modern software does.

Windows hoards your installers

I found no less than 28 GB of duplicate files. Notably, I had a whole Windows partition backup, from when I had a disaster and made a full partition dump before reinstalling, which caused the duplicate finder to search through what would have normally been hidden/system folders (by default, the software doesn’t look into those). And it found a bunch of duplicated installers in 2 Windows folders:
C:\Program Files (x86)\InstallShield Installation Information
and
C:\Windows\Installer

Apparently, Windows keeps installers (or a portion of them) there for uninstallation purposes. I guess that would be okay if all developers prepared just a small uninstaller for that purpose, but sadly quite a few of them are lazy and will just dump the whole freaking installer in there. Way to optimize space use… 😡
You can delete those if you want to reclaim the space, however you’ll then need the installer whenever you want to uninstall the concerned programs. So I’d recommend only deleting the really big ones, if any and if you think you won’t miss the easy uninstall option: in my case, the total contents of both folders were around 2.5 GB, with one installer taking up about 1 GB, so I only deleted that one.

Comodo and NVIDIA do a similar mess too

Comodo Firewall keeps its installer in C:\ProgramData\Comodo\Installer. But the very same installer is also kept in C:\Windows\Installer. Not sure how safe it is to delete one or the other (vis-à-vis the updates), so I kept both because it’s not too huge. At least, unlike NVIDIA, they don’t keep the whole freaking history!

You read right, I also found that NVIDIA keeps all its drivers installers (not just the last one) in C:\Program Files\NVIDIA Corporation\Installer2. And at the same time, Windows keeps them in C:\Windows\System32\DriverStore\FileRepository (folders named nvcvi.inf*). And this time it’s pretty huge: 2.5 GB in each folder. Yet, luckily, I skipped many driver updates: I assume someone who updates every time will get at least 10 wasted GB per year (probably a bunch more), unless maybe older versions start getting discarded after a certain quantity is reached.
Don’t get me wrong, I believe it makes sense to keep the previous installer, in case an update goes South (although it’s very easy to either keep the installer yourself, or just get it back from NVIDIA’s website). However, I see no point in keeping a lengthy history. So hurray, about 4 GB reclaimed, and on my system partition, too (which happens to be my smallest).
The ones in C:\Windows\System32\DriverStore\FileRepository can be a bit tricky to delete, but DriverStore Explorer, ran as administrator, should do the trick.

More to be found?

I only mentioned my main findings here, because the detailed list isn’t that relevant: it will depend on your setup, so my advice would be to run Duplicate Files Finder (or a similar program) yourself, making sure you configure it to search through all folders (meaning hidden and system folders too).

Of course, the usual common sense applies: investigate and think before you delete stuff. That means don’t delete stuff directly from the software, but do go have a look in the detected files’ folders first. And don’t delete stuff you’re not sure you can delete.
Also a tip: set a minimal file size to at least a few bytes: you most likely don’t want to bother with the super tiny files, and it will make the scan faster. From my first scan, I feel 50KB sounds a nice limit (NB: Duplicate Files Finder takes an input in bytes, so 50000)

Other various things I found this way (non-exhaustive list, just the biggest ones):

  • Kaspersky does the same thing as Comodo (keeps its installer in C:\ProgramData\Kaspersky Lab Setup Files but it’s also in C:\Windows\Installer
  • Intel Thunderbolt drivers: C:\Program Files (x86)\Intel\Thunderbolt Software\Drivers and C:\Windows\Installer
  • VeraCrypt: just keeps its whole installer in C:\Program Files\VeraCrypt (it’s not duplicated in C:\Windows\Installer but it’s still ridiculous)
  • Some utility specific to my laptop brand kept a copy of the .NET Framework installer for himself in C:\Program Files (x86)\Hotkey
  • Comodo again: it seems that I was wrong, they keep some kind of history, only in one place. It also has an alias, which is why my duplicate finder picked it up: C:\ProgramData\Comodo\CisDumps and C:\Users\All Users\Comodo\CisDumps

All in all, NVIDIA takes the cake by far though. If you want to play it lazy, that would be your one thing to clean.

Posted in nVidia, Windows, Windows 10.


Various old Greasemonkey scripts

With Firefox 57, due in a month and a half (November 14) Mozilla is going to break add-on things again. Big time. As of today, 9 out of the 12 add-ons I’m using are still using the old “legacy” format. Among those, an unknown proportion will probably never be updated and will be lost forever :/ Notably, Cookies Manager+ already stated it would be discontinued. And I’m also worried about Tamper Data, which is an awesome add-on to mess around POST requests and has been working great for the last 7 years without any update, apparently. (if you have some suggestions for _good_ replacements, I’d be glad to hear about them in the comments)

Anyway, Greasemonkey is one of the add-ons that’s going to be updated to follow the new trend, but in order to do so they chose to make some backwards incompatible changes. Meaning some old scripts will stop working. So I had a look at my scripts, and noticed I only have self-made ones, that I don’t really use anymore. I think I’ll just remove GM completely. Before doing so, I wanted to save my scripts… so I’ll just post them here 🙂

I’m not sure any of those still work, because the sites they target have probably evolved, but hopefully they might help someone do stuff. Most of them consist in evading annoying ads they weren’t caught by the usual uBlock, or anti-ad blockers. One was used to hide comments from specific users from some French IT news site. Without further ado, here they are all.

Posted in Firefox, Greasemonkey scripts.


Internet companies violating net neutrality

If you’ve been following the IT news lately, you should be aware of all the shitstorm that happened around Daily Stormer (DS). Long story short, their registrar GoDaddy kicked them out, and a chain reaction followed where many registrars and hosts kicked them out too. Sure they publish “weird” and mean contents, to say the least, but these are still legal contents. So, the companies who kicked them out chose to do so by their own initiative to censor the web. While on the other hand, they’ve regularly resisted to suspend law-braking contents such as piracy stuff.

Ironically, most of those companies pretend to be fighting for “net neutrality”, aka the concept that Internet Service Providers should be forced to carry traffic from all services equally, without any filtering. So what they’re saying is “do as we say, not as we do”. I understand private companies have a right to hand-pick their customers. It really doesn’t feel “right”, though, when said companies either enjoy a quasi-monopoly, or when said companies act all together as one. Also, I don’t see how it makes sense to force ISPs not to discriminate but to let other internet companies do so.

Anyhow, here is the list, that I’ll try to update as I find new ones, of companies who kicked customers based on internal censorship criteria that go farther than legal requirements:

  • GoDaddy: kicked DS domain name (source). Claim to be for net neutrality
  • Google: held DS domain name hostage (source). Claim to be for net neutrality. They also pulled Gab (a Twitter-like where free speech is real, be it left or right) out of the Play Store. Update (2017-09-01): Of course, by now it should be no secret that Google are cyberbullies.
  • Apple: also refused Gab on the App Store, and worse they allow a fake app to use its name. Update (2017-08-31): claim to be for net neutrality
  • OVH: kicked the DS domain name and hosting (source, in French). I don’t think they’ve ever been very vocal about net neutrality, although they once complained that ISPs wanted to charge them for some of the huge bandwidth they use
  • Facebook: closed Andrew Auernheimer’s account (one of DS’s staff, who didn’t post controversial stuff on his FB personal account) (source). Claim to be for net neutrality
  • Namecheap: kicked DS domain name (source). Claim to be for net neutrality so much that they dedicated a whole domain name for that propaganda
  • Twitter but that’s no secret they’re a censorship/PC heaven
  • CloudFlare: stood for free speech for a few days but eventually kicked DS too while having the nerve to explain why their own decision was badClaim to be for net neutrality
  • OpenDNS/Cisco Umbrella: are blocking DS domain name.
    This one is really special: other companies were companies that refused DS as a customer (breaking their contracts with unacceptably short notices, though). While in my opinion this is some worrisome censorship (because 1. it’s not easy to find alternatives that will accept DS and 2. it paves the way to legitimate a lot more censorship: if those companies start cherry-picking contents, they are effectively making themselves responsible for all the contents they do accept), I guess that in a way it is fair game. OpenDNS’s case is different: DS was never their customer. Their customers are just internet users, like you and me, who chose to ditch their ISP’s DNS servers in order to bypass whatever censorship their ISP/government might try to enforce on them. They don’t expect OpenDNS DNS servers to perform their own censorship too. OpenDNS acts pretty much like a “partial ISP” (the part that resolves DNS), but a particularly non-neutral one as I don’t know of any ISP that censors domain names without a proper government request to do so.
    And there is more: they were actually a victim of the lack of net neutrality a while back. Apparently they don’t mind doing to others what they suffered from in the past.
    Update (2017-08-30): OpenDNS now seems to resolve DS domain name properly. No idea if the temporary blackout was intended or not…
  • Network Solutions, LLC: held Stormfront’s domain name hostage (source). I didn’t find anything about their stance on net neutrality, they seem to be a pretty small company so I assume they didn’t make a lot of noise on the subject.
  • Protonmail: deactivated the e-mail account of Lee Rogers (DS staff member) (source). They too have very vigorously campaigned for net neutrality.

And a few ones who really can’t be qualified as posing an issue of net neutrality, but are still an illustration of the political correctness censorship in large/dominant tech companies:

Update (2017-09-05 and later): some more, with fewer details because the list is really getting too long:

Okay, there is just a problem with this post: I was only able to find censorship targeting the right. I wish I could find some targeting the left, in order to show that I don’t care which side of the political spectrum is targeted but I only care about the web having a censorship problem, but I just couldn’t find any… If you do have some of such examples, which do not involve obviously illegal stuff, please do let me know in the comments.

Posted in web filtering.


Why Tomtop’s products all have high ratings

For those who don’t know it, Tomtop is one of those sites that will ship you products straight from China, at pretty competitive prices. I recently bought a Xiaomi phone there, simply because Xiaomi still doesn’t bother to sell locally so buying abroad was my only option.

After browsing around the products a bit, I have yet to see a single product with an average rating below 4/5 stars. But I think I found the reason why.
That Xiaomi phone I bought, well it’s pretty bad. I mean, sure it works and it’s (very) cheap considering the hardware specs. However, I bought it primarily to experiment with LineageOS (RIP Cyanogenmod), and the bootloader is locked, and I spent almost 2 weeks trying to unlock it, with no success, and I eventually gave up. Xiaomi’s unlocking procedure, while straightforward on paper (request “permission” – I guess that’s the Chinese way of life -, download official tool, run said tool), is actually horrible and broken. If it works, good for you. If it doesn’t, you are screwed. They have no notion of what customer support means. The “support” is the forums, period. Forums where official staff barely ever intervene and lots of clueless people like to post their non-working solutions to your issues.

Anyhow, so of course I posted a negative review on Tomptop, precising that the phone was a PITA to unlock. And over a week later, said negative review is still not published. The review is in the system, I can view it in my member area (but not modify it), but it doesn’t appear publicly and isn’t counted in the rating or review count. The phone still has almost 5 full stars, with a bit less than 10 reviews. How many negative ones where kept in limbo? Only Tomtop knows…

So, don’t trust Tomtop’s ratings: the negative ones seem to be missing. And be also wary of the reviews: don’t get me wrong, I have no reason to believe they are fake, but since you only get the positive reviews you are only getting a very incomplete picture.

Posted in reviews.


How to transfer files on Android with ADB

For my current Windows installation, I chose an “N LTSB” version. N means without Media Feature Pack (no Windows Media Player, meaning it also lacks a bunch of codecs and some more surprising stuff), LTSB (for “Long-term servicing branch”) means that it’s free of shit like the Windows Store, Cortana, and most bundled apps (including Microsoft Edge). Also worth noting that unlike the default start menu of Windows 10, the start menu of 10 N LTSB is free of shitty tiles: there is only one, the “Contact Support” tile, which I consider an okay one, for once.

Among the surprising missing stuff in the “N” edition is, as I eventually was able to find out, the ability to browse a plugged smartphone using Windows Explorer. At first I thought this was a problem with the phone/Android drivers / ADB setup. But no, file transfers from an Android phone use the Media Transfer Protocol (MTP), which as its name suggests was included in the “Windows Media” framework. So on Windows N, no way to enjoy transferring your files the easy way.

The easy solution, of course, is to install the Media Feature Pack. But then there’s no point in getting an N version is it? (actually, I discussed with a Windows N user who told me they bought N because it was cheaper than the normal version in the store they bought it, in which case it does make sense to buy N and then download the Media Feature Pack)

The not as easy solution, which works nicely but might be not very convenient for a regular use, is to use ADB in the console. It’s actually fairly easy:
To get a shell on the phone (useful to browse and find the path to the files you want):
adb shell

Then you can browser like a normal Linux shell (cd path/to/folder, ls, etc)
To transfer a file from your phone to your computer:
adb pull /path/on/the.phone c:/path/on/the.computer

And to transfer a file from your computer to your phone:
adb push c:/path/on/the.computer /path/on/the.phone

For my path examples, I used Windows-style paths, but the commands are exactly the same on Linux or Mac OS.

On a side note, a notable path: although it probably depends on smartphones, photos and screenshots should be around /mnt/sdcard/DCIM and /mnt/sdcard/Pictures

Sources:

How to Push and Pull Files on Android using the ADB commands

Using adb To Copy Files To / From Your Android Device

Posted in multimedia, Windows 10.

Tagged with .


How to use pregenerated voice messages in game voicecoms

Lately, I’ve been playing a game called Friday the 13th. One of the originality of this game (which I don’t recommend at the moment due to the developpers’ very rude behavior towards the customers) is that it comes with a range-based voicechat: everyone, friend or foe, can hear you at a short distance, plus friends car hear you far away if both of you are equipped with a walkie-talkie.
This comes at a price, though: the devs thought it would be smart to only implement voicechat, meaning the game neither has text chat nor some kind of communication wheel with pre-recorded messages. In other words: no microphone = no communication. At all.

This sucks if: you do have no mic, or you don’t want to use a headset (mic can’t really be used without a headset because there doesn’t seem to be any kind of echo cancellation), or you don’t want to be noisy in the house because you play late, or if you’re a mute, etc.

People with no coms are also a weakness in the survivor (“counselor”) team, so eventually there was a rant topic on the Steam forums about people not using a mic, and in this thread a mute guy posted how he worked around the issue, by using software which basically created his own custom communication wheel. And here is how, with some tweaks so as to only use free (as in beer) or open source software.

Step 1: generate pre-recorded messages with text-to-speed software. Balabolka (freeware, Windows only) is nice for that, and very easy to use: type your message, choose between the 2 available voices (one male, one female), optionnally tweak it (I like to make it a bit faster, it saves time and since the pronounciation is good it’s still very understandable)

Step 2: install a “virtual audio cable” driver. That’s basically a driver that will create a device which can both act as a sound input and take sound input from another program. VB-Audio Virtual Cable (donationware, Windows only) will do nicely, and will be sufficient in its free version (if you donate, you get access to a version with more virtual audio cables, but you only need one for our purpose.

Step 3: get a soundboard software, like EXP Soundboard (open source and free, cross-platform – Java). This will allow you to map your sound files to hotkeys (I advise picking combined hotkeys, like ALT+X, so as to avoid accidentally playing sounds), and to send those sounds to both your speakers and your virtual audio cable. You can also configure the audio gain (separately for both outputs), meaning you can tweak the volume without having to redo your audio files, and you can choose different volumes from your local feedback (no need to make it too loud, this will allow you to hear game sounds better while “talking”) and your voice chat.
Of course, don’t forget to save your configuration 😉 It’s saved in a JSON file, which you should be able to manually edit if you want to re-order the sounds (which can’t been done from the software itself, apparently)

Step 4: don’t forget to configure your audio input in Steam, in Settings → Voice → Recording (audio input) device, otherwise the game won’t see it (that’s a little sad though, it means you can’t mix mic input and soundboard input – although I guess maybe the soundboard could be configured to also transmit mic input? I didn’t try that)

And voilà, you’re good to go. I didn’t go deep in each software’s details, but they are all pretty straightfoward so you shouldn’t have much difficulties setting them up.

Posted in multimedia, software.


And this is how I switched back from Vivaldi to Firefox

When Vivaldi came out a bit more than a year ago, I was rather enthusiastic about it, even though I remembered what the same people did to Opera and even though it was yet another Blink-based browser aka Google slave. I was always happy to add new browsers to my panel, in order to run multiple sessions simultaneously, and after all it was nice to have a fast browser for a change (Firefox/Cyberfox were still quite slow for me as I was on Win 7: they seem to perform a lot better on Win 10).

However, things eventually changed. First, Cyberfox was discontinued, and on this occasion I found out that it’s possible (and trivial) to run multiple independent sessions simultaneously with just Firefox. That was quite the revelation, and I promptly dropped Cyberfox and also Pale Moon, which was getting a bit outdated and was now failing to run Flash (having a contained Flash environment was basically the only reason I kept it around). After that, I was basically 60% Firefox, 40% Vivaldi.

Second, Vivaldi was regularly updated and improved. However, version 1.9 was a disaster: it completely broke the autocompletion in the address bar (it already used to be inferior to the autocompletion in Firefox, it became even worse, only providing one unique suggestion and only if you typed the exact beginning of the URL – worthless). I’ve also always been very unhappy with the SOCKS proxy support in Vivaldi, which is the same as Chrome = use the system-defined (same as Internet Explorer) proxy settings. I use one SOCKS proxy per separate session, so a browser not able to live its own life, distinct from the system settings, was a drag. Last but not least, I’ve always been annoyed by how Vivaldi doesn’t remember where to save/pick files on a per-site basis like Firefox seems to do pretty well.

At this point, I had only 2 reasons to keep using Vivaldi: Speed Dial, for which Firefox doesn’t seem to provide a suitable equivalent (no I don’t want to install an add-on just for that), and the fact that I couldn’t be bothered to migrate my session manually.

That was, until disaster stroke. I sent a tab to a new window, forgot all about it, and when I closed the browser I closed the primary window first. In case that shit never happened to you, what happens then is that when you restart your browser, the last closed window is restored (so, the one with just a tab, instead of my primary window that had 20-ish tabs). In Firefox, the History menu allows you to restore your 2 latest closed windows, meaning that in case you fuck up like that, you can easily recover (it happened to me a bunch of times). In Vivaldi, you’re fucked.
So, bye bye Vivaldi, I’ll just keep you around for testing when doing web development…

Posted in Chrome/Chromium/Vivaldi, Firefox.


JavaScript: passing arguments to setTimeout()

JavaScript prides itself on by asynchronous, which I find causes more complications than it solves, as in most cases I need code to execute step by step and not all at the same time. It makes, in my opinion, a lot more sense to have extra complications in the rare cases where I need asynchronous than to have extra complications in the very common cases where I need synchronous.

Among the trivial things that get unnecessarily complicated with asynchronous by default, is pausing. In many programming languages, when you want to pause, it’s just a matter of a trivial line, for instance:
– in PHP: sleep(X)
– in Python: time.sleep(X) (you need to import time for this to work, though)

In JavaScript, you’ll have to refactor your code, putting what you want to delay inside a separate function, and use setTimout(). That is, unless you want to saturate the CPU with an infinite loop for X seconds.

setTimeout() looks simple enough at first:

setTimeout(myDelayedFunction, 1000);

But there is a catch if you want to pass arguments. For instance, this won’t work (arg1 and arg2 will appear to myDelayedFunction as undefined):

setTimeout(function(){
    myDelayedFunction(arg1, arg2);
}, 1000);

To passe arguments to the function inside, you’ll have to use this:

setTimeout(function(A, B){
    myDelayedFunction(A, B);
}, 1000, arg1, arg1);

Or also this should work too (not tested)

setTimeout(myDelayedFunction, 1000, arg1, arg1);

Source and other variations there on Stackoverflow

Posted in JavaScript / TypeScript / Node.js, programming.