Skip to content

Instantly share code, notes, and snippets.

@sermonis
sermonis / README.md
Created August 17, 2021 14:06 — forked from superguigui/README.md
Three-orbit-controls with rotation set methods

I added a few methods to three-orbit-controls to be able to manually define phi or theta and be able to rotate to a given point.

// rotation in Y
controls.setAzimuthalAngle(theta);

// rotation in X
controls.setPolarAngle(phi);
/**
* Converts a XYZ vector3 to longitude latitude (Direct Polar)
* @param Lng longitude
* @param Lat latitude
* @param Vector3 optional output vector3
* @returns a unit vector of the 3d position
*/
function lonLatToVector3 ( lng, lat, out ) {
out = out || new THREE.Vector3();
var p1={
x:0,
y:0
};
var p2={
x:0,
y:1
};
@sermonis
sermonis / angle-between-points.js
Last active June 29, 2021 18:20 — forked from conorbuck/angle-between-points.js
JavaScript: Find the angle between two points
var p1 = {
x: 20,
y: 20
};
var p2 = {
x: 40,
y: 40
};
@sermonis
sermonis / GlobeControls.js
Last active July 6, 2021 15:14 — forked from dorian-moffroid-prolexia/GlobeControls.js
iTowns 2.8.0 GlobeControls.dispose() patch
// Source: https://github.com/iTowns/itowns
// Fork: https://github.com/sermonis/three-globe-map-itowns
/* globals window */
import * as THREE from 'three';
import AnimationPlayer, { Animation } from 'Core/AnimationPlayer';
import Coordinates, { ellipsoidSizes } from 'Core/Geographic/Coordinates';
import CameraUtils from 'Utils/CameraUtils';
import StateControl from 'Controls/StateControl';
@sermonis
sermonis / carfollow.js
Created June 10, 2021 14:11 — forked from photonstorm/carfollow.js
Car follow path + boost
var config = {
type: Phaser.AUTO,
width: 800,
height: 600,
backgroundColor: '#2d2d2d',
parent: 'phaser-example',
scene: {
preload: preload,
create: create,
update: update
@sermonis
sermonis / README.md
Last active March 18, 2021 16:09 — forked from nerdyman/README.md
Prompt a File Download and respect the Content Disposition Header Using Fetch and FileSaver

Prompt a File Download With the Content Disposition Header Using JavaScript

Set the Server Response Headers

Expose the Content-Disposition header using the Access-Control-Expose-Headers header and set the Content-Disposition header as you would usually.

Access-Control-Expose-Headers: Content-Disposition
Content-Disposition: attachment; filename="example-file.csv"
@sermonis
sermonis / index.js
Last active January 19, 2021 07:16
LIS Map scraping for Habr (https://habr.com/ru/post/302766/)
var log = require('cllc')();
var tress = require('tress');
var needle = require('needle');
var cheerio = require('cheerio');
var fs = require('fs');
var sCookie = 'http://www.puntolis.it/storelocator/defaultsearch.aspx?idcustomer=111';
var sProv = 'http://www.puntolis.it/storelocator/buildMenuProv.ashx?CodSer=111';
var sLoc = 'http://www.puntolis.it/storelocator/buildMenuLoc.ashx?CodSer=111&ProvSel=%s';
var sMarker = 'http://www.puntolis.it/storelocator/Result.aspx?provincia=%s&localita=%s&cap=XXXXX&Servizio=111';
@sermonis
sermonis / A Nuxt.js VPS production deployment.md
Created December 23, 2020 07:15 — forked from DreaMinder/A Nuxt.js VPS production deployment.md
Deployment manual for a real-world project built with nuxt.js + koa + nginx + pm2

Example of deployment process which I use in my Nuxt.js projects. I usually have 3 components running per project: admin-panel SPA, nuxt.js renderer and JSON API.

This manual is relevant for VPS such as DigitalOcean.com or Vultr.com. It's easier to use things like Now for deployment but for most cases VPS gives more flexebillity needed for projects bigger than a landing page.

UPD: This manual now compatible with nuxt@2.3. For older versions deployment, see revision history.


Let's assume that you have entered fresh installation of Ubuntu instance via SSH. Let's rock:

@sermonis
sermonis / nuxt.config.js
Created February 26, 2020 09:50 — forked from mjgartendev/nuxt.config.js
An example nuxt.config.js file heavily commented from the nuxt and vue-meta documentation examples
module.exports = {
/*
Headers of the page
- Nuxt.js uses vue-meta to update the headers and html attributes of your application.
- Nuxt.js configures vue-meta with these options:
{
keyName: 'head', // the component option name that vue-meta looks for meta info on.
attribute: 'data-n-head', // the attribute name vue-meta adds to the tags it observes
ssrAttribute: 'data-n-head-ssr', // the attribute name that lets vue-meta know that meta info has already been server-rendered
tagIDKeyName: 'hid' // the property name that vue-meta uses to determine whether to overwrite or append a tag