Skip to content

Instantly share code, notes, and snippets.

@sindresorhus
sindresorhus / esm-package.md
Last active April 26, 2024 03:53
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.
@iOnline247
iOnline247 / $sp-no-jquery.js
Last active March 10, 2021 21:03
Wrapper for SharePoint REST API.
/*!
* Created by Matthew Bramer
* Released under the MIT license
* Date: 2016-07-11
* Props to: http://blogs.msmvps.com/windsor/2015/02/13/reduce-code-need-for-rest-api-calls-with-sprestrepository/
* Tested using SharePoint Online & 2013 On-Prem.
*/
// http://sharepoint.stackexchange.com/questions/74978/can-i-tell-what-version-of-sharepoint-is-being-used-from-javascript
@wictorwilen
wictorwilen / AppOnly-ACS-PowerShell-Sample.ps1
Last active April 21, 2024 09:04
SharePoint Online: App Only policy PowerShell tasks with ACS
# For more information see: http://www.wictorwilen.se/sharepoint-online-app-only-policy-powershell-tasks-with-acs
$clientId = "<INSERT YOUR CLIENT ID HERE>"
$secret = "<INSERT YOUR CLIENT SECRET HERE>";
$redirecturi = "<INSERT YOUR REDIRECT URI HERE>"
$url = "https://<TENANT>.sharepoint.com/sites/contoso/"
$domain = "<TENANT>.sharepoint.com"
$identifier = "00000003-0000-0ff1-ce00-000000000000"
@zplume
zplume / LS.SP.JSOM.js
Last active June 30, 2023 15:04
SharePoint 2013 REST / JSOM / Utility functions (work in progress)
(function() {
var nsName = "LS"; // root namespace name
var ns = window[nsName]; // root namespace alias
var utils = ns.Utils; // utils alias
ns.SP = ns.SP || {};
ns.SP.JSOM = {
Data: {
Sites: {} // cache for Taxonomy terms JSON
},
@HaNdTriX
HaNdTriX / image_to_data_url.js
Last active February 27, 2022 07:23
Convert an image to base64URL.
/**
* Converts an image to a dataURL
* @param {String} src The src of the image
* @param {Function} callback
* @param {String} outputFormat [outputFormat='image/png']
* @url https://gist.github.com/HaNdTriX/7704632/
* @docs https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement#Methods
* @author HaNdTriX
* @example
*

Node.js Resources

What is node.js?

Node.js is just JavaScript running on the server side. That's it. That's all there is to it.

Express

  • Express Docs, if you want to get started and already know JavaScript this is the place to be
@brettz9
brettz9 / html5-dataset.js
Last active April 29, 2023 14:58
Dataset Shim
/**
* Add dataset support to elements
* No globals, no overriding prototype with non-standard methods,
* handles CamelCase properly, attempts to use standard
* Object.defineProperty() (and Function bind()) methods,
* falls back to native implementation when existing
* Inspired by http://code.eligrey.com/html5/dataset/
* (via https://github.com/adalgiso/html5-dataset/blob/master/html5-dataset.js )
* Depends on Function.bind and Object.defineProperty/Object.getOwnPropertyDescriptor (polyfills below)
* All code below is Licensed under the X11/MIT License
/**
Code copyright Dustin Diaz and Ross Harmes, Pro JavaScript Design Patterns.
**/
// Constructor.
var Interface = function (name, methods) {
if (arguments.length != 2) {
throw new Error("Interface constructor called with " + arguments.length + "arguments, but expected exactly 2.");
}
this.name = name;