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 / download_images.py
Created October 27, 2019 15:50
Download images from the web with Python using the Pillow and the requests libraries
import requests
from PIL import Image
from io import BytesIO
# Target image URL
url = "https://i.imgur.com/EdAGGFS.jpg"
# Get the text after the last slash in the URL, that is, the file name,\
# which includes its extension
file_name = url.split("/")[-1]
@Ze1598
Ze1598 / tweet_screenshot_template.py
Last active October 29, 2019 15:01
Create tweet screenshots including a user profile picture, its username and handle and the actual tweet body
from PIL import Image, ImageDraw, ImageFont
from textwrap import wrap
# Constants
# -----------------------------------------------------------------------------
# Set the font to be used
FONT_USER_INFO = ImageFont.truetype("arial.ttf", 90, encoding="utf-8")
FONT_TEXT = ImageFont.truetype("arial.ttf", 110, encoding="utf-8")
# Image dimensions (pixels)
WIDTH = 2376
@Ze1598
Ze1598 / app.component.html
Created November 20, 2019 13:18
Modal component: app.component.html
<main id="logout-button-holder">
<button mat-raised-button id="logout-button" (click)="openModal()">Logout</button>
</main>
@Ze1598
Ze1598 / app.component.css
Created November 20, 2019 13:22
Modal component: app.component.css
#logout-button {
color: white;
background-color: #4b4b4b;
border: 1px solid black;
}
@Ze1598
Ze1598 / styles.css
Created November 20, 2019 13:24
Modal component: styles.css
html, body {
height: 100%;
}
body {
margin: 0;
font-family: Arial, Helvetica, sans-serif;
display: grid;
justify-items: center;
align-items: center;
@Ze1598
Ze1598 / app.component.ts
Created November 20, 2019 13:30
Modal component: app.component.ts
import { Component } from '@angular/core';
import { MatDialog, MatDialogConfig } from '@angular/material/dialog';
import { ModalComponent } from './modal/modal.component';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
@Ze1598
Ze1598 / modal.component.html
Created November 22, 2019 16:20
Modal component: modal.component.html
<div id="modal-content-wrapper">
<header id="modal-header">
<h1 id="modal-title">Are you sure you want to logout?</h1>
</header>
<section id="modal-body">
<p>If you logout bad things might happen, but don't mind me, I'm just the description in a modal...</p>
</section>
<footer id="modal-footer">
<button mat-raised-button id="modal-action-button" (click)="actionFunction()">Logout</button>
<button mat-raised-button id="modal-cancel-button" (click)="closeModal()">Go back</button>
@Ze1598
Ze1598 / modal.component.css
Created November 22, 2019 16:27
Modal component: modal.component.css
#modal-content-wrapper {
width: 100%;
height: 100%;
display: grid;
grid-template-rows: repeat(1fr, 3);
}
#modal-title {
font-size: 22px;
}
@Ze1598
Ze1598 / modal.component.ts
Created November 22, 2019 17:04
Modal component: modal.component.ts
import { Component, OnInit } from '@angular/core';
import { MatDialogRef } from '@angular/material/dialog';
@Component({
selector: 'app-modal',
templateUrl: './modal.component.html',
styleUrls: ['./modal.component.css']
})
@Ze1598
Ze1598 / app.module.ts
Created November 22, 2019 20:54
Modal component: app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { MatButtonModule } from '@angular/material/button';
import { MatDialogModule } from '@angular/material/dialog';
import { ModalComponent as ModalComponent } from './modal/modal.component';