Skip to content

Instantly share code, notes, and snippets.

View jsdbroughton's full-sized avatar
🐒
coiled spring

Jonathon Broughton jsdbroughton

🐒
coiled spring
View GitHub Profile
@mrdoob
mrdoob / README.md
Created December 23, 2020 10:23
Three.js Converters (Node.js)

Utilities for converting model files to the Three.js JSON format. It's necessary to install the esm npm package before you can use the converters.

obj2three.js

Usage:

node -r esm obj2three.js model.obj
<template>
<div class="googleyolo">
<v-btn light v-if="!loggedIn && useLoginButton" @click="login">Login</v-btn>
<v-menu v-if="user" bottom left offset-y>
<v-btn slot="activator" icon large>
<v-avatar size="32px">
<img
:src="user.picture"
alt="profile_picture"
>
@brunobraga95
brunobraga95 / copyFirestoreDB.js
Last active August 12, 2021 14:35
Copy firestore database
const firebase = require('firebase-admin');
var serviceAccountSource = require("./source.json"); // source DB key
var serviceAccountDestination = require("./destination.json"); // destiny DB key
const sourceAdmin = firebase.initializeApp({
credential: firebase.credential.cert(serviceAccountSource)
});
const destinyAdmin = firebase.initializeApp({
@vlasky
vlasky / point_in_polygon_using_winding_number.js
Last active June 21, 2024 07:00
JavaScript implementation of winding number algorithm to determine whether a point is inside a polygon
//JavaScript implementation of winding number algorithm to determine whether a point is inside a polygon
//Based on C++ implementation of wn_PnPoly() published on http://geomalgorithms.com/a03-_inclusion.html
function pointInPolygon(point, vs) {
const x = point[0], y = point[1];
let wn = 0;
for (let i = 0, j = vs.length - 1; i < vs.length; j = i++) {
let xi = vs[i][0], yi = vs[i][1];
let xj = vs[j][0], yj = vs[j][1];
@DawidMyslak
DawidMyslak / vue.md
Last active April 22, 2024 12:49
Vue.js and Vuex - best practices for managing your state

Vue.js and Vuex - best practices for managing your state

Modifying state object

Example

If you have to extend an existing object with additional property, always prefer Vue.set() over Object.assign() (or spread operator).

Example below explains implications for different implementations.

@Spencer-Easton
Spencer-Easton / exportSpreadsheet.gs
Last active July 3, 2024 08:29
Example on how to export a Google sheet to various formats, includes most PDF options
function exportSpreadsheet() {
//All requests must include id in the path and a format parameter
//https://docs.google.com/spreadsheets/d/{SpreadsheetId}/export
//FORMATS WITH NO ADDITIONAL OPTIONS
//format=xlsx //excel
//format=ods //Open Document Spreadsheet
//format=zip //html zipped
@austinhyde
austinhyde / js-observables-binding.md
Last active August 16, 2023 18:19
Vanilla JavaScript Data Binding

Observables

You don't really need a framework or fancy cutting-edge JavaScript features to do two-way data binding. Let's start basic - first and foremost, you need a way to tell when data changes. Traditionally, this is done via an Observer pattern, but a full-blown implementation of that is a little clunky for nice, lightweight JavaScript. So, if native getters/setters are out, the only mechanism we have are accessors:

var n = 5;
function getN() { return n; }
function setN(newN) { n = newN; }

console.log(getN()); // 5

setN(10);

@soundTricker
soundTricker / datastore.js
Created May 17, 2013 11:02
Google Apps ScriptからCloud Datastore APIへのクエリ
function myFunction() {
var option = googleOAuth_();
option.method = "post";
option.contentType = 'application/json';
option.payload = JSON.stringify({
"query":
{
"kinds":
[
@jsdbroughton
jsdbroughton / GoogleSheetPDF.js
Last active April 28, 2022 18:42
Function to convert a given Google Spreadsheet [Sheet] into a PDF.
/**
* Function to convert a given Google Spreadsheet [Sheet] into a PDF.
*
* @param {string} key This is the Id of the Sheet to be converted bothe the DocsList.getId() and the SpreadsheetApp.getId() versions work
* @param {string} name [Optional] Intended Filename. If omitted, uses the Sheet filename.
* @param {object} options Settings object for the crafting of the PDF. Defaults to A4, no gridline print etc. <pre>
* {
* format:Enum,
* size:Enum,
* headers: Bool,
@juanpabloaj
juanpabloaj / DriveUpload.js
Last active May 13, 2020 22:17 — forked from rcknr/DriveUpload.gs
xls attached to google spreadsheet
function uploadXls(file) {
authorize();
var key = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // <-- developer key
var metadata = { title: file.getName() }
var params = {method:"post",
oAuthServiceName: "drive",
oAuthUseToken: "always",
contentType: "application/vnd.ms-excel",
contentLength: file.getBytes().length,
payload: file.getBytes()