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
<?php | |
/* | |
Project: PHP stock market web scraping | |
Author: Gabriel Diniz | |
Version: 1.0 | |
*/ | |
require_once( __DIR__ . '/simple_html_dom.php' ); | |
$stock = file_get_html('https://br.advfn.com/mundo/brasil'); |
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
<?php | |
/* | |
Script: Get URL Parts in PHP | |
Author: Gabriel Diniz | |
*/ | |
$url = 'https://www.example.com/pathname?queryname=googley'; | |
//FULL PARSING | |
var_dump(parse_url($url)); |
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
//Clone the full project on: https://github.com/dinizgb/nextjs-weather-widget-with-styled-components | |
import React, { useState, useEffect } from "react"; | |
import Image from 'next/image'; | |
import styled from 'styled-components'; | |
const WeatherWidgetWrapper = styled.div` | |
min-width: 250px; | |
background: #fff; | |
border: 1px solid #e8eaff; |
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
//Clone the full project on: https://github.com/dinizgb/nextjs-weather-widget-with-styled-components | |
import React, { useState, useEffect } from "react"; | |
import Image from 'next/image'; | |
import styled from 'styled-components'; | |
const WeatherWidgetWrapper = styled.div` | |
min-width: 250px; | |
background: #fff; | |
border: 1px solid #e8eaff; |
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
//Clone the full project on: https://github.com/dinizgb/nextjs-weather-widget-with-styled-components | |
import React, { useState, useEffect } from "react"; | |
import Image from 'next/image'; | |
import styled from 'styled-components'; | |
const WeatherWidgetWrapper = styled.div` | |
min-width: 250px; | |
background: #fff; | |
border: 1px solid #e8eaff; |
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
import React, { Component } from 'react'; | |
import styled from 'styled-components'; | |
import ScrollContainer from 'react-indiana-drag-scroll'; | |
const MenuSticky = styled.div` | |
width: 100%; | |
padding: 10px 0; | |
display: -moz-box; | |
display: -webkit-box; | |
top: 0; |
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 to add or decrease days to a date | |
* @param {string} date - With the date (With at least yyyy-mm-dd date format) | |
* @param {number} days - With the days | |
* @param {boolean} action - True to increase days or false to decrease days | |
* @returns {string} With the the new date | |
*/ | |
export const addOrDecreaseDaysToDate = (date: string, days: number, action: boolean): string => { | |
const result = new Date(date); | |
action ? result.setDate(result.getDate() + days) : result.setDate(result.getDate() - days); |
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 to get the difference in Days between two dates | |
* @param {string} date1 - With the date 1 (With at least yyyy-mm-dd date format) | |
* @param {number} date2 - With the date 2 (With at least yyyy-mm-dd date format) | |
* @returns {number} With the difference in days | |
*/ | |
export const differenceInDays = (date1: string, date2: string): number => { | |
const d1 = new Date(date1); | |
const d2 = new Date(date2); | |
const timeDiff = d2.getTime() - d1.getTime(); |
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 to get last dates within a determined period | |
* @param {Number} period - With the period | |
* @returns {Array} With an Array with dates in ISO format (YYYY-MM-DDTHH:MM:SS.sssZ) as string | |
*/ | |
export const getLastDatesWithinPeriod = (period: number): Array<string> => { | |
const today = new Date(); | |
const days = []; | |
for (let i = 0; i < period; i++) { | |
const day = new Date(today); |