Skip to content

Instantly share code, notes, and snippets.

View matthewoestreich's full-sized avatar
♠️
👋

Matt Oestreich matthewoestreich

♠️
👋
View GitHub Profile
This file has been truncated, but you can view the full file.
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
router.post('/createServer', function (req, res, next) {
try {
let server = req.body;
io.of(server.endpoint).on('connection', (socket) => {
console.log('Socket connected!');
socket.on('messageToServer', (message) => {
console.log('Message on socket');
@matthewoestreich
matthewoestreich / index.js
Created June 7, 2020 22:34
Vanilla Node.js with Mustache
const http = require('http');
const fs = require('fs');
const mustache = require('mustache');
const hostname = '127.0.0.1';
const port = 3000;
const server = http.createServer((req, res) => {
if (req.url === '/') {
if (req.method === 'GET') {
@matthewoestreich
matthewoestreich / react_styled-components_babel.html
Last active May 26, 2020 02:48
React, Styled Components, Babel: HTML Boilerplate
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- CHANGE PAGE TITLE -->
<title>Page Title</title>
<style>
html * {
<!DOCTYPE html>
<html>
<body>
<!-- Try to put all script tags at the bottom of the <body>-->
<!-- The `event` argument in `rollDice(event)` is a special variable name. It contains data about the event,
which we can access in our function. If you tried to use `rollDice(xyz)`, event data would not be passed. -->
<button id="dice-roller" onclick="rollDice(event)">Roll Dice</button>
<!--Uncomment the line below, and remove the line above, to test with assigning event handlers programmatically-->
@matthewoestreich
matthewoestreich / start-firefox-as-different-profile.sh
Created April 3, 2020 00:14
Start Firefox using different profile - also allows you to create profiles
#!/bin/bash
/Applications/Firefox.app/Contents/MacOS/firefox-bin -no-remote -P dev &
@matthewoestreich
matthewoestreich / .1.Rect-Boilerplate
Last active April 3, 2020 01:59
React Webpack from scratch
React boilerplate
@matthewoestreich
matthewoestreich / .prettierrc
Created March 29, 2020 20:59
prettier react boilerplate
{
"printWidth": 100,
"arrowParens": "avoid",
"jsxBracketSameLine": false,
"singleQuote": true,
"trailingComma": "all",
"tabWidth": 2,
"bracketSpacing": true
}
@matthewoestreich
matthewoestreich / .eslintrc
Created March 29, 2020 20:18
eslint-react-boilerplate
{
"parser": "babel-eslint",
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 8,
"ecmaFeatures": {
"jsx": true
}
},
"env": {
var express = require('express');
var bodyParser = require('body-parser')
var cors = require('cors')
var main = express()
main.use(cors())
var server = main.listen(8000);
var io = require('socket.io').listen(server);