Skip to content

Instantly share code, notes, and snippets.

View OctaneInteractive's full-sized avatar
🏠
Working from home

Wayne Smallman OctaneInteractive

🏠
Working from home
  • Yorkshire, England.
View GitHub Profile
@sindresorhus
sindresorhus / esm-package.md
Last active November 27, 2024 10:56
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@theKAKAN
theKAKAN / getDirection.js
Created February 14, 2021 17:09
Convert degrees or angles to cardinal direction
function getDirection( angle ){
// We divide it into 16 sections
let directions = ["N","NNE","NE","ENE","E",
"ESE", "SE", "SSE","S",
"SSW","SW","WSW","W",
"WNW","NW","NNW" ];
// This means, every 360 / 16 degree, there's a section change
// So, in our case, every 22.5 degree, there's a section change
// In order to get the correct section, we just need to divide
let section = parseInt( angle/22.5 + 0.5 );
@lmj0011
lmj0011 / rejson-for-ubuntu.md
Last active November 4, 2024 10:18
Building and Loading the ReJSON v1 Module on Linux Ubuntu 16.04 for Redis

make sure you have at least redis v4.0+

redis-server --version

redis-cli --version

install the build-essential package

apt-get install build-essential

@vbiamitr
vbiamitr / index.html
Last active January 29, 2023 10:43
SVG based Select / Dropdown element using D3
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="https://d3js.org/d3.v4.min.js">
</script>
<script src="https://unpkg.com/babel-standalone@6/babel.min.js">
</script>
<style>
body {
@chlab
chlab / README.md
Last active April 28, 2021 09:48
vue webpack boilerplate: how to add env-specific build targets

When using the vue-webpack-boilerplate, you will have only a production build by default (besides dev and test setups). My team often has at least another environment we call "staging" where the client can test new features before we move them to production. Oftentimes, these environments will have env-specific config values, like a different API URL.

With the changes outlined below, you can create a separate config per environment. This assumes you've created a Vue.js project with vue-webpack-boilerplate.

  1. Apply the changes to the corresponding files in your project as outlined below
  2. Now, when you run npm run build staging it will build your project with the config values specific to your staging environment. You can easily add any number of other environments and build them the same way. npm run build or npm run build production will still build your production environment.
@andrei-tofan
andrei-tofan / example.js
Last active February 29, 2024 23:59
node.js writable buffer stream (pdfkit example)
/**
* Convert PDFDocument to Base64
*/
const PDFDocument = require('pdfkit');
const stream = require('./stream');
// crate document and write stream
let doc = new PDFDocument();
let writeStream = new stream.WritableBufferStream();
@scottopolis
scottopolis / splice-object-array.js
Last active January 31, 2023 06:54
Remove object from array of objects in Javascript
// we have an array of objects, we want to remove one object using only the id property
const apps = [{id:34,name:'My App',another:'thing'},{id:37,name:'My New App',another:'things'}];
// get index of object with id of 37
const removeIndex = apps.findIndex( item => item.id === 37 );
// remove object
apps.splice( removeIndex, 1 );
@iworkforthem
iworkforthem / gist:4981da2e587b921edd7257dcbbb43945
Created January 10, 2017 02:43
remove mongodb on amazon ec2.
sudo service mongod stop
sudo yum erase $(rpm -qa | grep mongodb-org)
sudo rm -r /var/log/mongodb
sudo rm -r /var/lib/mongo
@davisford
davisford / Setup MongoDB on localhost as Replica Set
Last active May 14, 2024 06:37
Setup MongoDB replica set on local host with only a single primary
Add the `replication` section to the mongod.conf file:
```
$cat /usr/local/etc/mongod.conf
systemLog:
destination: file
path: /usr/local/var/log/mongodb/mongo.log
logAppend: true
storage:
engine: mmapv1
@lexuschert
lexuschert / WordShuffler.js
Created November 17, 2016 12:39
WordShuffler
/**
* from http://codepen.io/SaschaSigl/pen/woGYKJ
*/
function WordShuffler(holder,opt){
var that = this;
var time = 0;
this.now;
this.then = Date.now();
this.delta;