Skip to content

Instantly share code, notes, and snippets.

@fabiomolinar
fabiomolinar / FossilFuelsCassavaConfig.hs
Last active December 21, 2021 17:22
Code snippets related to my FossilFuels.hs module.
type Country = String
type Code = String
type Year = Int
type Value = Double
data Entry = Entry { country :: !Country
, code :: !Code
, year :: !Year
, value :: !Value
} deriving (Show)
type Trend = [Entry]
@fabiomolinar
fabiomolinar / FastDegrade.hs
Created December 13, 2021 20:46
Second version of my Haskell code which I used to create an image with an array of colorful squares.
{-|
Module : FastDegrade
Description : Creates an image with multiple squares of different colors.
Copyright : (c) Fabio Thomaz MOlinar, 2021
Maintainer : fabiomolinar@gmail.com
Stability : experimental
Second attempt at trying to make a module that create an image with multiple
squares of different colors on it. The first attempt, the module 'Degrade'
had a __terrible__ performance.
@fabiomolinar
fabiomolinar / Degrade.hs
Created December 13, 2021 20:37
First version of my Haskell code which I used to create an image with an array of colorful squares.
{-|
Module : Degrade
Description : Creates an image with multiple squares of different colors.
Copyright : (c) Fabio Thomaz MOlinar, 2021
Maintainer : fabiomolinar@gmail.com
Stability : experimental
This was my first attempt at creating a module that would be able to create an
image with multiple squares of different colors. Although it works, the efficiency
is __TERRIBLE__.
@fabiomolinar
fabiomolinar / Django-CMS - page creation error
Created November 12, 2018 08:46
Django-CMS - 'module' object has no attribute 'allowed_elements'
Environment:
Request Method: POST
Request URL: http://localhost:8000/en/cms_wizard/create/
Django Version: 1.11.16
Python Version: 2.7.15
Installed Applications:
('djangocms_admin_style',
@fabiomolinar
fabiomolinar / react-tips.md
Last active September 20, 2018 15:11
Tips and tricks not to forget when programming React components.

React Tip

Sources

Writing code

  • It's a good practice to wrap components definitions with parenthesis.
@fabiomolinar
fabiomolinar / linux-permissions.md
Last active September 4, 2018 18:53
Tips and commands related to Linux file permissions, users and groups.

Linux permissions

In Linux, each and every file is owned by a single user and a single group, and has its own access permissions.

Users

To list all users on a Linux machine:

cat /etc/passwd

@fabiomolinar
fabiomolinar / docker-tips.md
Last active September 7, 2018 06:41
Tips on running and using docker.

Docker tips

Source:

  • Learning Docker (Book)
  • Authors: Jeeva S. Chelladhurai, Vinod Singh, Pethuru Raj

Networking

Useful commands include: docker network connect, docker network create, docker network disconnect, docker network inspect, docker network ls, and docker network rm.

Default networks include:

  • bridge
@fabiomolinar
fabiomolinar / docker-best-practices
Created August 30, 2018 12:53
Docker best practices
https://docs.docker.com/develop/develop-images/dockerfile_best-practices/
@fabiomolinar
fabiomolinar / dockerfile-summary.md
Last active September 1, 2018 12:09
Summary of chapter 3 from the book "Learning Docker"

Dockerfile cheat sheet

Source:

  • Learning Docker (Chapter 3)
  • Author: Jeeva S. Chelladhurai, Vinod Singh, Pethuru Raj

As we discussed in the previous chapter, we can craft an image manually by launching a container from a base image, install all the required applications, make the necessary configuration file changes, and then commit the container as an image. As a better alternative, we can resort to the automated approach of crafting the images using Dockerfile, which is a text-based build script that contains special instructions in a sequence for building the correct and relevant images from the base images. The sequential instructions inside Dockerfile can include selecting the base image, installing the required application, adding the configuration and the data files, and automatically running the services as well as exposing those services to the external world. Thus, the Dockerfile-based automated build system has simplified the image-building process remarkably. It also offers a great deal of

@fabiomolinar
fabiomolinar / useful-docker-commands.md
Last active December 10, 2018 14:02
List of useful Docker commands

List of useful Docker commands

Source:

  • Learning Docker (Book)
  • Authors: Jeeva S. Chelladhurai, Vinod Singh, Pethuru Raj

docker run

The docker run subcommand takes an image as an input and launches it as a container. You have to pass the -t and -i flags to the docker run subcommand in order to make the container interactive. The -i flag is the key driver, which makes the container interactive by grabbing the standard input (STDIN) of the container. The -t flag allocates a pseudo-TTY or a pseudo Terminal (Terminal emulator) and then assigns that to the container. In the following example, we are going to launch an interactive container using the ubuntu:16.04 image and /bin/bash as the command:

$ sudo docker run -i -t ubuntu:16.04 /bin/bash