Skip to content

Instantly share code, notes, and snippets.

View shealan's full-sized avatar
👋

Shealan Forshaw shealan

👋
View GitHub Profile
@davidobrien1985
davidobrien1985 / stored-proc.js
Last active December 22, 2023 10:59
Cosmos DB Stored Procedure to update all documents based on query with a new property called inventoryStatus. Change lines 27 and 37 to create a different property.
function addProperty(continuationToken) {
var response = getContext().getResponse();
var collection = getContext().getCollection();
var updated = 0;
if (continuationToken) { // Parse the token
var token = JSON.parse(continuationToken);
if (!token.queryContinuationToken) {
throw new Error('Bad token format: no continuation');
@phuze
phuze / dropbox-php-auth.md
Last active June 5, 2024 19:32
Dropbox API V2: PHP Authentication Process

Effective September 2021, Dropbox will be deprecating long-lived access tokens.

This GIST generally describes how to authenticate requests to Dropbox API v2, for anyone working on a server-side PHP Dropbox implementation.

It's important to understand three types of codes you'll encounter:

  1. Access Code - this is a one-time code that represents user-granted app access.
  2. Access Token - this is short-lived token that provides access to Dropbox API endpoints.
  3. Refresh Token - this is a long-lived token that allows you to fetch a fresh Access Token.
@MastaAaron
MastaAaron / category-schema.js
Last active May 20, 2023 09:50
Sanity CMS: Infinitely-nestable Categories
export default {
name: `category`,
title: `Category`,
type: `document`,
fields: [
{
name: `name`,
title: `Category Name`,
type: `string`,
validation: Rule => Rule.required()
@ojczeo
ojczeo / index.js
Last active August 25, 2023 03:19
audiowaveform for lambda - https://github.com/bbc/audiowaveform
// install first binaries from http://ffxsam.s3.amazonaws.com/public/audiowaveform-lambda.zip
// @author Andrzej Ojczenasz https://github.com/ojczeo
// @version '1.0.0'
'use strict';
process.env.PATH = process.env.PATH + ':' + process.env.LAMBDA_TASK_ROOT + '/bin';
function getExtension(filename) {
var ext = path.extname(filename||'').split('.');
return ext[ext.length - 1];
@Slauta
Slauta / .gitlab-ci
Last active March 18, 2024 16:53
electron-updater from private repo gitlab.com
variables:
VERSION_ID: '1.0.$CI_PIPELINE_ID'
stages:
- build
build:
image: slauta93/electron-builder-win
stage: build
artifacts:
@adamwathan
adamwathan / promise-take-at-least.js
Last active February 26, 2023 14:25
Promise.takeAtLeast
// Creates a new promise that automatically resolves after some timeout:
Promise.delay = function (time) {
return new Promise((resolve, reject) => {
setTimeout(resolve, time)
})
}
// Throttle this promise to resolve no faster than the specified time:
Promise.prototype.takeAtLeast = function (time) {
return new Promise((resolve, reject) => {
@mattattui
mattattui / -README.md
Last active July 12, 2017 14:28
API Status component

Call it like this:

<api-status theme="dark" status-endpoint="/api/status"></api-status>

It uses window.fetch() which you might have to polyfill if you haven't already: yarn add whatwg-fetch

The component expects a JSON response with a property called message. If it's non-empty, it'll show the message. Pretty straightforward.

<?php
/**
* Assumes https://github.com/Spomky-Labs/jose library is installed and autoloading is set up
* Decode and verify token guide: https://github.com/Spomky-Labs/jose/blob/master/doc/operation/Verify.md
*/
use Jose\Factory\JWKFactory;
use Jose\Loader;
// We load the key set from a URL
// JSON Key URL (JKU) - https://cognito-idp.{region}.amazonaws.com/{userPoolId}/.well-known/jwks.json.
@paulsturgess
paulsturgess / service.js
Last active February 2, 2024 17:24
An example Service class wrapper for Axios
import axios from 'axios';
class Service {
constructor() {
let service = axios.create({
headers: {csrf: 'token'}
});
service.interceptors.response.use(this.handleSuccess, this.handleError);
this.service = service;
}
@shealan
shealan / gulpfile.js
Last active November 11, 2016 01:19
Gulp workflow with sass compile, js minification and postcss processing.
/* gulp dependencies */
const gulp = require('gulp');
const sass = require('gulp-sass');
const uglify = require('gulp-uglify');
const rename = require('gulp-rename');
const notify = require('gulp-notify');
const minifycss = require('gulp-minify-css');
const concat = require('gulp-concat');
const plumber = require('gulp-plumber');
const browserSync = require('browser-sync');