Skip to content

Instantly share code, notes, and snippets.

Valde Waltari10

Block or report user

Report or block Waltari10

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Dockerfile
# Get Nginx image from Docker hub
FROM nginx
# Copy our configuration file to a folder in our Docker image where Nginx will use it
COPY default.conf.template /etc/nginx/conf.d/default.conf.template
# Configure Nginx for Heroku
CMD /bin/bash -c "envsubst '\$PORT' < /etc/nginx/conf.d/default.conf.template > /etc/nginx/conf.d/default.conf" && nginx -g 'daemon off;'
# Update available packages in Debian
RUN apt-get update
# Install curl cmd line tool
RUN apt-get install curl -y
View js
componentDidUpdate() {
if (this.state.members === '' || this.state.members === undefined) {
this.props.fetchHousingGovernmentMembers();
}
if (this.state.members !== this.props.members) {
this.setState({ members: this.props.members });
}
View start.js
// exec allows us to run cmd commands in code
const { exec } = require('child_process');
// process.env.PORT is defined by Heroku environment. Use 3200 as fallback if outside of Heroku.
const port = process.env.PORT || 3200;
console.log('Port: ' + port)
const cmdStr = `.\\node_modules\\.bin\\serve -l ${ port} ./build`
console.log(cmdStr)
View app.js
import React, { useState } from 'react';
import logo from './logo.svg';
import './App.css';
function App() {
const [response, setResponse] = useState('')
return (
<div className="App">
View server.js
// Comes with Node
const http = require('http');
// Access dynamic Heroku port with process.env.PORT. 3001 is a fallback.
const port = process.env.PORT || 3001;
// Create a server
const server = http.createServer((req, res) => {
// If call was made to /hello-world pathname. We aren't using REST here!
if (req.url === '/hello-world') {
View start.js
// execSync allows us to run system commands synchronously
const { execSync } = require('child_process');
// process.env.PORT is defined by Heroku environment. Use 3200 as fallback if outside of Heroku.
const port = process.env.PORT || 3200;
// Same as runnin "npm run serve" in terminal
execSync(`npm run serve -- -l ${ port} ./build`, (err, stdout, stderr) => {
if (err) {
// node couldn't execute the command
View HTML tyylittely.html
<div
ng-include="'list-group-item-actions-toggle-button'"
ng-repeat="item in [person]"
>
sisältöä
</div>
View javaaa
"use strict";
var WebSocketServer = require('ws').Server
, wss = new WebSocketServer({ port: 8080 });
var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'localhost',
user : 'root',
password : 'password',
You can’t perform that action at this time.