Skip to content

Instantly share code, notes, and snippets.

View Ze1598's full-sized avatar

José Fernando Costa Ze1598

  • Porto, Portugal
View GitHub Profile
@Ze1598
Ze1598 / modal.component.ts
Created December 28, 2019 19:02
Reusable modal component: modal.component.ts (final version)
import { Component, OnInit, Inject } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { ModalActionsService } from 'src/app/services/modal-actions.service';
@Component({
selector: 'app-modal',
templateUrl: './modal.component.html',
styleUrls: ['./modal.component.css']
})
export class ModalComponent implements OnInit {
@Ze1598
Ze1598 / mock-serv-1.service.ts
Created December 28, 2019 19:11
Reusable modal component: mock-serv-1.service.ts
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class MockServ1Service {
constructor() { }
alertLogout(modalData: any) {
@Ze1598
Ze1598 / mock-serv-2.service.ts
Created December 28, 2019 19:13
Reusable modal component: mock-serv-2.service.ts
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class MockServ2Service {
constructor() { }
alertDelete(modalData: any) {
@Ze1598
Ze1598 / modal-actions.service.ts
Created December 28, 2019 19:23
Reusable modal component: modal-actions.service.ts (final version)
import { Injectable } from '@angular/core';
import { MockServ1Service } from './mock-serv-1.service';
import { MockServ2Service } from './mock-serv-2.service';
@Injectable({
providedIn: 'root'
})
export class ModalActionsService {
constructor(
@Ze1598
Ze1598 / collect_internet_speeds.py
Last active January 7, 2020 19:20
Collect internet speeds: collect_internet_speeds.py
# https://github.com/sivel/speedtest-cli
import speedtest as st
import pandas as pd
from datetime import datetime
def get_new_speeds():
speed_test = st.Speedtest()
speed_test.get_best_server()
@Ze1598
Ze1598 / line_plot_demo.py
Last active January 16, 2020 23:38
Matplotlib intro: line plots
from matplotlib import pyplot as plt
nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
doubles = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
squares = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
plt.plot(nums, doubles, label="Doubles", color="red")
plt.plot(nums, squares, label="Squares", color="blue")
plt.xlabel("Number")
@Ze1598
Ze1598 / scatter_plot_demo.py
Created January 15, 2020 19:46
Matplotlib intro: scatter plots
from matplotlib import pyplot as plt
x_coords = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
fav_nums = [9, 37, 45, 32, 46, 56, 28, 9, 16, 68, 64, 100, 25, 1, 59, 50, 31, 96, 13, 76]
plt.scatter(x_coords, fav_nums, marker="x", color="red")
plt.ylabel("Favorite number")
plt.xticks([])
plt.title("Favorite number of twenty individuals")
@Ze1598
Ze1598 / pie_chart_demo.py
Last active January 16, 2020 23:38
Matplotlib intro: pie charts
from matplotlib import pyplot as plt
slices = [1, 9, 3, 3, 4]
labels = ["Management", "Sales", "Quality Assurance", "Accounting", "Human Resources"]
colors = ["#ff9999", "#66b3ff", "#99ff99", "#ffcc99", "#cccccc"]
plt.pie(slices, labels=labels, colors=colors, autopct="%1.2f%%")
plt.title("Size of departments at Company A")
plt.tight_layout()
@Ze1598
Ze1598 / bar_chart_demo.py
Created January 15, 2020 19:55
Matplotlib intro: bar chart
from matplotlib import pyplot as plt
pairs_owned = [16, 9, 9, 6]
options = ["One", "Two", "Three", "Four+"]
plt.bar(options, pairs_owned)
plt.title("Years of experience working with Python (n=40)")
plt.ylabel("Number of respondents")
plt.tight_layout()
@Ze1598
Ze1598 / bar_hor_chart_demo.py
Created January 15, 2020 19:57
Matplotlib intro: horizontal bar chart
from matplotlib import pyplot as plt
pairs_owned = [16, 9, 9, 6]
options = ["One", "Two", "Three", "Four+"]
plt.barh(options, pairs_owned)
plt.title("Years of experience working with Python (n=40)")
plt.xlabel("Number of respondents")
plt.tight_layout()