This file contains 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
* | |
!package.json | |
!package-lock.json | |
!server.js |
This file contains 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
'use strict'; | |
const {inspect} = require('util'); | |
const readonly = value => ({ | |
configurable: true, | |
value, | |
}); | |
// Not to be considered a URL. |
This file contains 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
#!/usr/bin/env python2 | |
# -*- coding: utf-8 -*- | |
import ast | |
import codeop | |
def try_get_context(source_lines, lineno, limit=10): | |
# does not try very hard | |
line = source_lines[node.lineno - 1] |
This file contains 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
app.use(session({ | |
store: store, | |
secret: config.sessions.secret, | |
cookie: { maxage: 30 * 24 * 60 * 60 * 1000, secure: true }, | |
resave: false, | |
saveUninitialized: false | |
})) | |
app.get('/loginrefresh', function (req, res) { | |
console.log(req.session) |
This file contains 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
exports.playlistExists = (name, playlists) => ({ | |
index: playlists.findIndex(p => p.name.toLowerCase() === name.toLowerCase()), | |
}); | |
exports.createPlaylist = name => | |
exports.playlists() | |
.then(playlists => exports.playlistExists(name, playlists.items)) | |
.then(response => { | |
if (response.index === -1) { |
This file contains 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
#!/usr/bin/env node | |
'use strict'; | |
const https = require('https'); | |
const semver = require('semver'); | |
const readUtf8 = stream => | |
new Promise((resolve, reject) => { | |
const parts = []; |
This file contains 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 scanNext = lastEvaluatedKey => | |
scan(lastEvaluatedKey) | |
.tap(data => { | |
console.log(++counter, data.Count, data.LastEvaluatedKey); | |
}) | |
.then(data => | |
data.LastEvaluatedKey ? | |
scanNext(data.LastEvaluatedKey) : | |
Promise.resolve() | |
); |
This file contains 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
macro selected(page) | |
if page === currentPage | |
.selected | |
a href: "/" selected('home') | |
a href: "/about" selected('about') | |
a href: "/contact" selected('contact') |
This file contains 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 Query { | |
constructor(text, values) { | |
this.text = text; | |
this.values = values; | |
} | |
} | |
const sql = (parts, ...values) => { | |
let text = parts[0]; |
This file contains 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
// Marshals a string to Uint8Array. | |
function encodeUTF8(s) { | |
var i = 0; | |
var bytes = new Uint8Array(s.length * 4); | |
for (var ci = 0; ci != s.length; ci++) { | |
var c = s.charCodeAt(ci); | |
if (c < 128) { | |
bytes[i++] = c; | |
continue; | |
} |
NewerOlder