Skip to content

Instantly share code, notes, and snippets.

View mikaelvesavuori's full-sized avatar

Mikael Vesavuori mikaelvesavuori

View GitHub Profile
@mikaelvesavuori
mikaelvesavuori / es6-checker.js
Created February 10, 2018 17:48
Check if ES6 is totally supported
var supportsES6 = function() {
try {
new Function("(a = 0) => a");
return true;
}
catch (err) {
return false;
}
}();
@mikaelvesavuori
mikaelvesavuori / using-wget-to-scrape-a-site.md
Created February 22, 2018 20:13
Using wget to scrape a site

Using wget to scrape a site

You can easily scrape (or download) a site with a CLI tool called wget. It's available for Linux, Mac and Windows.

Installation

I recommend using Homebrew, especially if you're on a Mac, to install it.

brew install wget

Scraping a site

@mikaelvesavuori
mikaelvesavuori / instant-mac-setup.sh
Created March 4, 2018 09:56
Instant Mac Setup: This will run mikaelvesavuori/dotfiles without any previous download
echo "Instant Mac Setup: This will run mikaelvesavuori/dotfiles without any previous download";
git clone https://github.com/mikaelvesavuori/dotfiles.git
cd dotfiles
sh setup-mac.sh
@mikaelvesavuori
mikaelvesavuori / good-base-gitignore
Created March 13, 2018 18:37
Good base .gitignore
### Node ###
# Dependency directories
/node_modules
# dotenv environment variables file(s)
.env
.env.*
# Build generated
@mikaelvesavuori
mikaelvesavuori / node-fs-functions-copy-rename
Created April 1, 2018 19:48
Node functions to copy files, folders (recursively), and rename files
const fs = require('fs');
const path = require('path');
function copyFile(source, target) {
let targetFile = target;
if (fs.existsSync(target) && fs.lstatSync(target).isDirectory()) targetFile = path.join(target, path.basename(source))
fs.writeFileSync(targetFile, fs.readFileSync(source));
}
@mikaelvesavuori
mikaelvesavuori / writing-and-reading-ssh-keys-on-mac
Created April 4, 2018 07:11
Writing and reading SSH keys on Mac
# Generate key
ssh-keygen -t rsa -b 4096
# Copy public key to clipboard
pbcopy < ~/.ssh/id_rsa.pub
@mikaelvesavuori
mikaelvesavuori / troubleshooting-npm-yarn-gulp-node
Last active April 15, 2018 15:52
Troubleshooting NPM, Yarn, Gulp, Node
# Gist: Troubleshooting Gulp and NPM
## Unclean installation/execution errors via NPM (ENOENT, no such file, cannot find...)
Lots of things you can usually fix with the following two-step procedure.
In your CLI:
- npm update
- npm install
- If using sass: npm rebuild node-sass
## Problems with access rights (Windows)
{
"emmet.triggerExpansionOnTab": true,
"eslint.packageManager": "yarn",
"tslint.enable": true,
"tslint.jsEnable": true,
"workbench.colorTheme": "Palenight Theme",
"workbench.startupEditor": "newUntitledFile",
"html.format.wrapLineLength": 200,
"typescript.check.npmIsInstalled": true,
"javascript.validate.enable": false,
@mikaelvesavuori
mikaelvesavuori / extend-webpack-config-example
Created May 23, 2018 13:26
Example of extending a Webpack config
const baseConfig = require("./webpack.config");
const path = require("path");
module.exports = Object.assign(
{},
{
target: "node",
entry: "./src/ServerApp.jsx",
output: {
filename: "server.bundle.js",
@mikaelvesavuori
mikaelvesavuori / vs-code-settings-20180712
Last active July 12, 2018 13:39
Visual Studio Code settings (dated 2018-07-12)
{
"terminal.integrated.rendererType": "canvas",
"terminal.integrated.fontFamily": "Fira Code",
"terminal.integrated.fontSize": 12,
"terminal.integrated.fontWeight": "100",
"terminal.integrated.fontWeightBold": "bold",
"editor.multiCursorModifier": "ctrlCmd",
"editor.fontFamily": "Fira Code, monospace",
"editor.fontLigatures": true,
"editor.fontSize": 13,