This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Node { | |
constructor(val=0, next=null) { | |
this.val = val; | |
this.next = next; | |
} | |
} | |
const generateLinkedList = (arr) => { | |
let current = new Node(); | |
const head = current; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// EVENTS | |
let event; | |
// create event | |
const createEvent = (newEvent, nationSlug, siteSlug, accessToken) => { | |
return fetch(`https://${nationSlug}.nationbuilder.com/api/v1/sites/${siteSlug}/pages/events?access_token=${accessToken}`, { | |
method: 'POST', | |
headers: { | |
'Content-Type': 'application/json', | |
'Accept': 'application/json', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const generateRandomAsciiString = (len, cap=false, lower=false, num=false, special=false) => { | |
let str = ''; | |
const includesCap = str => !![...Array(26)] | |
.map((n, i) => String.fromCharCode(i + 65)) | |
.filter(c => str.includes(c)).length; | |
const includesLower = str => !![...Array(26)] | |
.map((n, i) => String.fromCharCode(i + 97)) | |
.filter(c => str.includes(c)).length; | |
const includesNum = str => !![...Array(10)] | |
.map((n, i) => String.fromCharCode(i + 48)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Api::V1::PositionsController < ApplicationController | |
before_action :authorize_device! | |
def index | |
positions = Position.where(device_id: params[:id]).order(time: :desc) | |
render json: positions | |
end | |
def create | |
position = Position.new( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let someBoringPromise = new Promise((winner, loser) => winner()) | |
let anotherBoringPromise = new Promise((winner, loser) => loser()) | |
let someLessBoringPromise = new Promise((winner, loser) => winner(console.log("cat"))) | |
let anotherLessBoringPromise = new Promise((winner, loser) => loser(console.log("dog"))) | |
let someBoringPromiseWithPotential = new Promise((winner, loser) => winner("cat")) |