Skip to content

Instantly share code, notes, and snippets.

Avatar

Nikolaj lopugit

View GitHub Profile
@lopugit
lopugit / gist:dcff73fe104e5897599972bfcfd8aedd
Created Jan 29, 2021
run root command in wsl without starting user session, for recovering broke wsl init configs
View gist:dcff73fe104e5897599972bfcfd8aedd
If you only need to remove the script, try from cmd wsl.exe -u root -e rm /etc/profile.d/00-wsl2.systemd.sh.
If you have bad startup config in /etc/wsl.conf, perhaps you can run wsl -u root -e mv /etc/wsl.conf /etc/wsl.conf.bak.
EDIT: you know what -u root does, don't you ;) As for -e, it means do not invoke the default login shell and run the rm or mv binaries directly.
@lopugit
lopugit / Launch current node.js file VS code launch.json debugger debug
Created May 13, 2020
Launch current node.js file VS code launch.json debugger debug
View Launch current node.js file VS code launch.json debugger debug
{
"type": "node",
"request": "launch",
"name": "Current File",
"program": "${workspaceFolder}/${relativeFile}",
"skipFiles": [
"<node_internals>/**"
]
}
@lopugit
lopugit / set-up-chromium-keys.md
Created Dec 15, 2019 — forked from ezeeyahoo/set-up-chromium-keys.md
Launch Chromium with API Keys on Mac OS X and Windows
View set-up-chromium-keys.md

Sometimes you need to use API Keys to use things like the Speech API. And then you Google a bit and follow all the instructions. But the Chromium Project's API Keys page does a not-so-great of explaining how to do this, so I will.

  1. Download Chromium.[Unofficial/Unstable/Latest build] OR Download from https://github.com/macchrome/chromium/releases (stable)
  2. You'll notice a yellow disclaimer message appear as a doorhanger: Google API Keys are missing. Some functionality of Chromium will be disabled. Learn More.
  3. Clicking on that link takes you to the confusing API Keys docs page.
  4. If you aren't already, subscribe to the chromium-dev@chromium.org mailing list. (You can just subscribe to the list and choose to not receive any mail. FYI: the C
@lopugit
lopugit / DeterminingFunctionTypes.js
Created Dec 10, 2019
Determining function types
View DeterminingFunctionTypes.js
const flags = {
function: f instanceof Function,
name: undefined,
native: false,
bound: false,
plain: false,
arrow: false
};
if (flags.function) {
@lopugit
lopugit / default.conf
Created Jun 4, 2019
NGiNX Configuration for Vue-Router in HTML5 Mode
View default.conf
server {
listen 80 default_server;
listen [::]:80 default_server;
root /your/root/path;
index index.html;
server_name you.server.com;
@lopugit
lopugit / 1_primitive_comparison.js
Created May 5, 2019 — forked from nicbell/1_primitive_comparison.js
JavaScript object deep comparison. Comparing x === y, where x and y are values, return true or false. Comparing x === y, where x and y are objects, returns true if x and y refer to the same object. Otherwise, returns false even if the objects appear identical. Here is a solution to check if two objects are the same.
View 1_primitive_comparison.js
//Primitive Type Comparison
var a = 1;
var b = 1;
var c = a;
console.log(a == b); //true
console.log(a === b); //true
console.log(a == c); //true
console.log(a === c); //true
View bugs global factory
(function (globalThis, factory) {
if (typeof exports === 'object' && typeof module !== 'undefined')
if (typeof global === 'object')
return factory(global)
else
return factory(exports)
if (typeof define === 'function' && define.amd)
return define(['exports'], factory)
View eslint bugs
{
"env": {
"es6": true, // Use ES6 recommended
"node": true, // We code in node
"browser": true // We also code for browser
},
//"parser": "babel-eslint",
"extends": "eslint:recommended", // Use the recommended ESlint rules
"parserOptions": {
@lopugit
lopugit / drive-format-ubuntu.md
Created Jan 12, 2019 — forked from keithmorris/drive-format-ubuntu.md
Partition, format, and mount a drive on Ubuntu
View drive-format-ubuntu.md
@lopugit
lopugit / Isomorphic Fetch post body data empty solution
Last active Oct 3, 2018
Isomorphic Fetch post body data empty solution
View Isomorphic Fetch post body data empty solution
Client:
fetching with headers:
{ "Content-Type": "application/json" }
Stringifying JSON:
body: JSON.stringify(data)
Server: add:
app.use((req, res, next) => {
res.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
next();