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
function setWithExpiry(key, value, ttl) { | |
const now = new Date() | |
// `item` is an object which contains the original value | |
// as well as the time when it's supposed to expire | |
const item = { | |
value: value, | |
expiry: now.getTime() + ttl, | |
} | |
localStorage.setItem(key, JSON.stringify(item)) |
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
import RestocksService from '../../../services/supreme/RestocksService'; | |
import StorageService from '../../../services/StorageService'; | |
import ChromeService from '../../../services/ChromeService'; | |
export default class RestockMonitor { | |
constructor(intervalMs) { | |
this.intervalMs = intervalMs; | |
this.onNewProductsCallbacks = []; | |
this.onProductsRestockCallbacks = []; | |
} |
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
<button id="elem" onclick="alert('Click!');">Autoclick</button> | |
<script> | |
let event = new Event("click"); | |
elem.dispatchEvent(event); | |
</script> | |
<h1 id="elem">Hello from the script!</h1> | |
<script> |
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
https://a.jd.com//ajax/queryServerData.html | |
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
{"api":"mtop.common.getTimestamp","v":"*","ret":["SUCCESS::接口调用成功"],"data":{"t":"1586519130440"}} | |
http://api.m.taobao.com/rest/api3.do?api=mtop.common.getTimestamp | |
2.苏宁时间服务器接口api: | |
http://quan.suning.com/getSysTime.do |
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 users = JSON.parse( | |
fs.readFileSync(`${__dirname}/_data/users.json`, 'utf-8') | |
) |
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
var mySchema = new Schema({ | |
name: { | |
type: String | |
}, | |
createdAt: { | |
type: Date, | |
default: Date.now | |
} | |
}); |
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 crypto = require('crypto') | |
const mongoose = require('mongoose') | |
const bcrypt = require('bcryptjs') | |
const jwt = require('jsonwebtoken') | |
const uniqueValidator = require('mongoose-unique-validator') | |
const Schema = mongoose.Schema | |
const UserSchema = new Schema( |
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 objectToQueryString = queryParameters => { | |
return queryParameters | |
? Object.entries(queryParameters).reduce((queryString, [key, val], index) => { | |
const symbol = queryString.length === 0 ? '?' : '&'; | |
queryString += typeof val === 'string' ? `${symbol}${key}=${val}` : ''; | |
return queryString; | |
}, '') | |
: ''; | |
}; |
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
function getUrlParameter(name) { | |
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]'); | |
var regex = new RegExp('[\\?&]' + name + '=([^&#]*)'); | |
var results = regex.exec(location.search); | |
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' ')); | |
}; |