Skip to content

Instantly share code, notes, and snippets.

View DanSmaR's full-sized avatar
🏠
Working from home

Danilo Martins DanSmaR

🏠
Working from home
View GitHub Profile
// Sending an HTTP Request from a NodeJS server
//const http = require("http");
const https = require("https");
const Stream = require("stream").Transform;
const fs = require("fs");
https
.get("https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY", resp => {
// A BASIC Node server
// Routing Requests
const http = require("http");
const url = require("url");
const server = http.createServer(function(req, res) {
//console.log(req.url);
let parsedURL = url.parse(req.url, true);
let path = parsedURL.pathname;
// A BASIC Node server
const http = require("http");
const server = http.createServer(function(req, res) {
res.setHeader("Content-type", "application/json");
res.setHeader("Access-Control-Allow-Origin", "*");
res.writeHead(200); //status code HTTP 200 / OK
let dataObj = { id: 123, name: "Bob", email: "bob@work.org" };
@DanSmaR
DanSmaR / app.js
Created October 10, 2022 03:13 — forked from prof3ssorSt3v3/app.js
Using Express JS to serve static files
"use strict";
const express = require("express");
const app = express();
const port = process.env.port || 5005;
// https://expressjs.com/en/4x/api.html#express.static
let options = {
dotfiles: "ignore", //allow, deny, ignore
etag: true,
extensions: ["htm", "html"],
@DanSmaR
DanSmaR / app.js
Last active October 10, 2022 01:48 — forked from prof3ssorSt3v3/app.js
node express server code example
"use strict";
const data = require("./data"); //data.channels[n].id .name .last_update
const express = require("express");
const app = express();
app.use(express.json());
app.get("/api/channel", (req, res) => {
//return the list of channels
// respond with a 200
@DanSmaR
DanSmaR / mysql_cheat_sheet.md
Created September 24, 2022 16:25 — forked from bradtraversy/mysql_cheat_sheet.md
MySQL Cheat Sheet

MySQL Cheat Sheet

Help with SQL commands to interact with a MySQL database

MySQL Locations

  • Mac /usr/local/mysql/bin
  • Windows /Program Files/MySQL/MySQL version/bin
  • Xampp /xampp/mysql/bin

Add mysql to your PATH

/*
*********************************************************************
http://www.mysqltutorial.org
*********************************************************************
Name: MySQL Sample Database classicmodels
Link: http://www.mysqltutorial.org/mysql-sample-database.aspx
Version 3.2
+ changed the order of the CREATE TABLE and ALTER TABLE commands to work with MySQL 5.7
and issues with FOREIGN KEY CONSTRAINTS
Version 3.1
-- phpMyAdmin SQL Dump
-- version 4.8.5
-- https://www.phpmyadmin.net/
--
-- Host: localhost:8889
-- Generation Time: May 26, 2019 at 07:52 PM
-- Server version: 5.7.25
-- PHP Version: 7.3.1
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
-- phpMyAdmin SQL Dump
-- version 4.8.5
-- https://www.phpmyadmin.net/
--
-- Host: localhost:8889
-- Generation Time: May 18, 2019 at 01:20 PM
-- Server version: 5.7.25
-- PHP Version: 7.3.1
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
@DanSmaR
DanSmaR / docker-help.md
Created September 11, 2022 15:27 — forked from bradtraversy/docker-help.md
Docker Commands, Help & Tips

Docker Commands, Help & Tips

Show commands & management commands

$ docker

Docker version info