Skip to content

Instantly share code, notes, and snippets.

View numfin's full-sized avatar
💋

A coder numfin

💋
View GitHub Profile
class PromiseQueue {
constructor (limit = 20, cb = () => {}) {
/** @type {{promiseFn: () => Promise, cb: void}[]} */
this.queue = []
this.running = 0
this.limit = limit
this.cb = cb
}
let counter = 0;
const postIds = postsToDelete.map(val => val.getIdFromVal)
allPosts.forEach((val, index) => {
if (postsIds.contains(val.keyToCurrentPostId)){
allPosts.splice(index - counter, 1);
counter++;
}
})
switchToChannel({state, commit, dispatch}, channelID) {
const exists = this.selectByKey(state.channels, {key: '_id', value: channelID})
if (exists) {
Object.keys(channels).forEach(key => {
const id = channels[key]._id
if (id === channelID) {
commit('channel', channels[i])
}
})
} else {
{
"env": {
"browser": true,
"commonjs": true,
"es6": true,
"node": true
},
"parserOptions": {
"ecmaFeatures": {
"jsx": true
install vscode extentions:
eslint
prettier - code formatter
type this in console to install npm dependensies:
npm install eslint
npm install -g install-peerdeps
install-peerdeps --dev eslint-config-airbnb
F1 in vscode then type "eslint" and choose "create .eslintrc.json file"
in /form route
const pussy = `?client_id=${your client id here}&client_secret=${your client secret here}`
const foursquare = put foursquare link here. Be sure it ends in / or letter
// foursquare + pussy should be equal smth like http://link/?client_id...
request(foursquare + pussy, function ...
const body = {
message: 'hi'
}
const data = new FormData();
data.append( "json", JSON.stringify( body ) );
fetch("/echo/json/", {
method: "POST",
body: data
const auth = require(`./auth.js`)
const port = 3000
const request = require('request')
// require your modules
const express = require('express')
const bodyParser = require('body-parser')
// create instance of express
https://download.anydesk.com/linux/fedora24/anydesk-2.9.5-1.fc24.x86_64.rpm?_ga=2.163409471.2066833590.1515334281-1634431790.1515334281
// [GET USER FROM SERVER]
export const getAccessToken = ({ commit, dispatch }, { req }) => {
if (!req || !req.headers.cookie) return Promise.reject('no-cookie')
// [get new tokens]
return axios
.post(`https://securetoken.googleapis.com/v1/token?key=${projectID}`, {
grant_type: 'refresh_token',
refresh_token: Cookie.parse(req.headers.cookie).refresh
})
.then(res => {