Skip to content

Instantly share code, notes, and snippets.

View n3dst4's full-sized avatar
:octocat:
fgdxgfdxfg

Neil de Carteret n3dst4

:octocat:
fgdxgfdxfg
View GitHub Profile
@n3dst4
n3dst4 / destructuring.ts
Last active November 20, 2019 10:46
Destructuring tricks in JS or TS
// we'll be playing with this happy little object in these examples
const foo = {
bar: 1,
baz: 2,
corge: 3,
};
// 1. basic destructuring
{
const { bar } = foo;
@n3dst4
n3dst4 / ubuntu_efi_wtf.md
Created May 5, 2019 15:29
Ubuntu Linux EFI Grub Windows dual boot chaos

Ubuntu Linux EFI Grub Windows dual boot chaos

Situation: I had Ubuntu 18.10 successfully dual-booting with Windows 10. Tried to do_release_upgrade to 19.04 but it couldn't complete, probably because I had a million *-desktop packages installed and they'd trodden all over each other.

So I decided to install a fresh 19.04, using all defaults for everything. Install went smoothly but on reboot, there was no GRUB menu, just straight into Ubuntu.

After MUCH experimenting, it seems that the problem was that the default install was creating an "efi" partition which was effing it up somehow. The fix was to re-run the install, but instead of accepting the option to delete the previous Ubuntu and install over it, choose to "do something else", and manually the pick the partition to nuke and recreate. Do not create an efi partition.

It will piss and moan about not having an efi partition, but ignore it. It's fine, it will boot fine. Once you're up and running, pop a terminal and do:

@n3dst4
n3dst4 / screening.js
Last active March 28, 2019 16:16 — forked from rmurphey/screening.js
Rebecca Murphey's JS screening questions. Answers below.
// 1: how could you rewrite the following to make it shorter?
if (foo) {
bar.doSomething(el);
} else {
bar.doSomethingElse(el);
}
@n3dst4
n3dst4 / wsl_locales_profanity.markdown
Last active June 15, 2018 10:14
How to fix batshit WSL errors abut locales, $LANG, $LC_* etc

If you start getting shitty fucking error messages like

manpath: can't set the locale; make sure $LC_* and $LANG are correct

whenever you start up a WSL shell, your system locales are all fucked to insane buggery and you need to unfuck them pronto.

You can do this by running the official locale-unfucking command:

@n3dst4
n3dst4 / enable_ms_store.reg
Created March 29, 2018 13:21
How re-enable MS Store if your overzealous local IT have tried to disable it
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\WindowsStore]
"RemoveWindowsStore"=dword:00000000
@n3dst4
n3dst4 / switchy.js
Last active July 7, 2016 07:13
let + switch
// What is the console output of this code?
function switchFoo (foo) {
switch (foo) {
case 1:
foo = 5
console.log(foo)
case 2: {
console.log(foo)
break
@n3dst4
n3dst4 / README.md
Last active February 19, 2016 16:29
Using node-retry to work around errors in Windows when using rimraf

Deleting a tree of folders using rimraf can be pretty fraught on MS Windows; the OS itself can lock files randomly, and there may be various processes getting in the way, like virus checkers or cloud file syncing apps. rimraf itself will do an exponential-backoff-and-retry for EBUSY and ENOTEMPTY errors on Windows, but you can still see EPERM and others. If you want to do exponential-backoff-and-retry for any error, see the below recipe, using node-retry.

package main
import (
"fmt"
"math"
)
func Sqrt(x float64) (float64, int) {
last := 0.0
z := 1.0
@n3dst4
n3dst4 / pathshrink.sh
Created November 9, 2013 13:12
This is a bash script for use in Windows (for use with Cygwin/Git Bash etc) to shrink foldernames on shitty windows. Since shitty windows's shitty FS allows you to create files with a path length greater than the maximum allowable path length (!) you can end up with an undeletable folder structure. This script recurses through and renames everyt…
#!/bin/bash
# set this to the problem folder
BASE=/c/Users/ndc/Dropbox/projects/delete-me
cd $BASE
for i in `find $BASE -depth`
do
DIR=`dirname $i`
FILE=`basename $i`
@n3dst4
n3dst4 / no_caching.cs
Created November 8, 2013 13:32
Disabling absolutely all caching on an ASP.NET MVC controller action. Because this is always so much ballache.
Response.Cache.SetExpires(DateTime.UtcNow.AddDays(-1));
Response.Cache.SetValidUntilExpires(false);
Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetNoStore();