$ git fetch origin <sha>
Make sure the staging area is how you want the commit to be
$ git write-tree
const http = require('http') | |
const crypto = require('crypto') | |
const server = http.createServer((req, res) => { | |
console.log('got request', req.url) | |
res.writeHead(200, { 'Content-Type': 'text/plain' }) | |
res.end('okay') | |
}) | |
server.on('upgrade', function (req, socket) { |
type URLSearchParamsInit = ConstructorParameters<typeof URLSearchParams>[0]; | |
type ApiFormatMap = { | |
arrayBuffer: ArrayBuffer; | |
text: string; | |
json: object; | |
formData: FormData; | |
blob: Blob; | |
stream: ReadableStream<Uint8Array>; | |
response: Response; | |
}; |
type Optional<T, K extends keyof T = keyof T> = Omit<T, K> & Partial<Pick<T, K>>; | |
type AllOrNothing<T> = T | Partial<Record<keyof T, never>>; | |
type OnlyOne<T> = { | |
[K in keyof T]: ( | |
Required<Pick<T, K>> & Partial<Record<Exclude<keyof T, K>, never>> | |
) | |
}[keyof T]; | |
type Test = { |
/** | |
* @author Colin Richardson | |
* | |
* @description this script in combination with a chrome extension enviroment adds i18n capabilities to html pages without jQuery. | |
* html elements will need a data-i18n tag with the message name and will be placed within the elements innerHTML attribute. | |
* | |
* This can be expanded/modified with the use of data-i18n-attr and place the name of the attribute you wish to assign the message to. | |
* EG: title, value, etc etc | |
* EG: data-i18n-attr="title", data-i18n-attr="value", etc etc | |
* |
# Make octopus from current commit/index | |
commit_id=$(git commit-tree $(git write-tree) -p commit1 -p commit2 -p commit3 -m "Octopus Message") | |
git branch -f "tmp/octopus" "$commit_id" |
const express = require("express"); | |
const multer = require("multer"); | |
const upload = multer({"dest": "./mult"}); | |
const app = express(); | |
app.get("/", indexHandler); | |
app.post("/save", upload.single("fileField"), saveHandler); |
var _db; | |
module.exports = { | |
connect: function ({host = "localhost", port = 27017, dbname = "exampleDb"} = {}) { | |
return require("mongodb").MongoClient.connect(`mongodb://${host}:${port}/${dbname}`) | |
.then(db => _db = db); | |
}, | |
collection: function (col_name) { | |
if ( !_db ) { | |
return null; |
const Express = require("express"); | |
const methodOverride = require("method-override"); | |
const app = new Express(); | |
const router = new Express.Router(); | |
//app.use(methodOverride("_method", {"methods": ["POST", "GET"]})); // Works too. | |
router.use(methodOverride("_method", {"methods": ["POST", "GET"]})); // on route so only the following use the method override. | |
router.get("/:id", all("get")); |
// imports | |
const Express = require("express"); | |
const bodyParser = require("body-parser"); | |
// Some datastore to play with. | |
const bookDb = initDb(); | |
// Set up express app. | |
const app = new Express(); |