Last week I created this little minimalist app with vanilla JavaScript, having features such as current weather, to-do list, etc. It’s entirely open-source. Check its GitHub repository for more details.
From the project’s readme file:
Focus is an application that aims to help you better organize your day. It contains interesting features as well as astonishing background images and beautiful minimalist responsive design. It is built with vanilla JavaScript and its whole code weights less than 25kb!
I am sharing here a “GoToTop” React JS component that I created today. This component will render a button (shaped as an arrow) when the user scrolls down, past a certain point. When clicked, this button will execute a handleGoToTop() function that will smoothly scroll the screen back to the top.
This is a styled component, making it very portable. It also uses React hooks and TypeScript.
Among the several strategies aimed at increasing the productivity of a development team, the proper organization of the code related to the software being conceived undoubtedly occupies a preponderant place. Over the years, several methods and tools have been created for this purpose. It is important to know them, especially since they can very concretely result in a substantial saving of time, at least in terms of maintenance activities and bug fixing.
In this context, we’ll take a look at how to deploy styled components in a React JS project with TypeScript using the styled-components library. This technique allows components to contain their own styles. This “encapsulation” of styles also involves CSS in JS, using tagged template literals.
One more Rocketseat challenge completed!โ๏ธ ๐ ๐จ๐๐๐ซ๐ค๐๐ญ๐ฉ๐ฅ๐๐๐ is an e-commerce app, built with #ReactNative, #TypeScript and applying techniques such as #TDD, async storage and context API.
By default, browsers will block certain requests if both the client and the server are not in the same origin. Cross-origin resource sharing (CORS) is a specification designed to allow restricted resources from a remote server in a given origin, to be requested by a client associated to a different origin. An origin, as defined by the RFC6454, implies “identical schemes, hosts and ports”.
Usually the request from the browser will be accompanied by its corresponding HTTP headers, including the request’s origin. Example of the HTTP headers on the request:
When CORS is not enabled, the response will not contain the Access-Control-Allow-Origin header and the browser will likely block it, as illustrated by the diagram below.
Browsers will block most requests from different origins
For choosing between a html select or checkboxes on your form, just toggle the “multiple” parameter on the ChoiceType class. Since the roles are an array, we need a data transformer.
Example:
<?php
namespace App\Form;
use App\Entity\User;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\CallbackTransformer;
class UserType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('email')
->add('Roles', ChoiceType::class, [
'required' => true,
'multiple' => false,
'expanded' => false,
'choices' => [
'User' => 'ROLE_USER',
'Partner' => 'ROLE_PARTNER',
'Admin' => 'ROLE_ADMIN',
],
])
->add('password')
->add('groups')
;
// Data transformer
$builder->get('Roles')
->addModelTransformer(new CallbackTransformer(
function ($rolesArray) {
// transform the array to a string
return count($rolesArray)? $rolesArray[0]: null;
},
function ($rolesString) {
// transform the string back to an array
return [$rolesString];
}
));
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => User::class,
]);
}
}
#!/bin/bash
# ##########################################################################################
# #### Description
#
# Adjusts screen backlight brightness from command line. It takes as argument a percentage
# and calculates the final value, based on the maximum brightness of the monitor.
#
# Usage:
# qbb [percentage]
#
# Example for setting brightness to 50%:
# qbb 50
#
# Author: dth@dthlabs.com
# Date: July 9, 2019.
#
# ##########################################################################################
# #### Settings
# Full path of the 'max_brightness' file, containing the maximum brightness of the monitor
max_brightness_path="/sys/class/backlight/intel_backlight/max_brightness"
# Full path of the 'brightness' file, containing the current brightness of the monitor
current_brightness="/sys/class/backlight/intel_backlight/brightness"
# ##########################################################################################
# #### Main
# Get the argument
desired_brightness=$1
# Get the maximum brightness and put into a variable
max_brightness=$(cat "$max_brightness_path")
# Calculate the final value
final_value=$(($max_brightness * $desired_brightness / 100))
# Set the final value
echo $final_value > $current_brightness
# Return message
echo 'Setting the backlog value to' $final_value '('$desired_brightness'%' of $max_brightness')'
First you need to make sure that:
– Your LAMP is up and running
– You have a working DNS for the domain you want to use for gitlab
– You have certbot already installed
Part I – gitlab
Prepare the system for the gitlab install
apt-get update && apt-get upgrade
Install dependencies. Choose “internet site” and press enter.