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 | |
// simplest possible express app | |
var http = require('http'); | |
var express = require('express'); | |
var app = express(); | |
// while your program is running, requests to "/test" will trigger this | |
// callback function. | |
app.get("/test", function(req, res) { |
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
define("alpha", function () { | |
return {a: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
const handler = { | |
get (target, propKey){ | |
if(propKey === 'post'){ | |
return function(...args){ | |
if(!args[args.length - 1].hasOwnProperty('csrfToken') || !args[args.length - 1].hasOwnProperty('cookie')){ | |
return target[propKey](...args) | |
} | |
const csrf = args.pop(); | |
return target[propKey](...args) | |
.set('x-xsrf-token', csrf.csrfToken) |
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
<html> | |
<head> | |
<script> | |
if(navigator.serviceWorker.controller){ | |
console.log('Listen to SW'); | |
navigator.serviceWorker.controller.addEventListener('message', function(data){ | |
console.log('Data from service worker received'); | |
console.log(data) | |
}); | |
} |
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
export default class App extends Component { | |
render() { | |
return ( | |
<div> | |
<Provider store = {store}> | |
{()=><Router> | |
<Route path="/" component={FriendListApp}> | |
</Route> | |
</Router>} | |
</Provider> |
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
function MakeQuerablePromise(promise) { | |
// Don't create a wrapper for promises that can already be queried. | |
if (promise.isResolved) return promise; | |
var isResolved = false; | |
var isRejected = false; | |
// Observe the promise, saving the fulfillment in a closure scope. | |
var result = promise.then( | |
function(v) { isResolved = true; return v; }, |
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
describe("spec", function () { | |
var server, fakeData = [ {a:1}, {b:2}, {c:3} ]; | |
before(function () { | |
server = sinon.fakeServer.create(); | |
server.respondWith( | |
"GET", | |
"https://myhost.local/url/5", | |
[200, { "Content-Type": "application/json" }, JSON.stringify(fakeData)] | |
); |
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
var startErrorTracking = function(){ | |
window.addEventListener('error', function (err) { | |
var lineAndColumnInfo = err.colno ? ' line:' + err.lineno +', column:'+ err.colno : ' line:' + err.lineno; | |
push.call(this, 'FrontendError', | |
err.message, | |
err.filename + lineAndColumnInfo + ' -> ' + navigator.userAgent); | |
}); | |
}; |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
</head> | |
<body> | |
<script> | |
var wrk = new Worker('./w.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
TCP_IP. Сетевое администрирование, 3-е издание -- это супер базовое, наверное все уже читали | |
У. Р. Стивенс - UNIX. Разработка сетевых приложений |
NewerOlder