Skip to content

Instantly share code, notes, and snippets.

View FilippoBovo's full-sized avatar

Filippo Bovo FilippoBovo

View GitHub Profile
@FilippoBovo
FilippoBovo / amend_last_commit.sh
Last active October 28, 2023 18:29
Git Commands
git reset --soft HEAD~1 # Use HEAD~2 to amend the last 2 commits
# Amend files
git add .
git commit -m "<commit_message>"
git push --force
@FilippoBovo
FilippoBovo / awk_examples.sh
Last active September 6, 2023 22:40
Shell Snippets
awk -F':' '{ print $1 }' <file>
# Print the first column for a file whose columns are separated by ':'.
awk '$2 == 5'
awk '$2 == 5 { print $0}'
# Print the entire lines where the second column equals 5.
# Other comparison operators: == != < > <= >= ?:
awk '/tom|jerry|vivek/'
# Print Lines Containing tom, jerry AND vivek
@FilippoBovo
FilippoBovo / functional_programming_in_python_resources.md
Last active April 7, 2023 13:02
Functional Programming in Python - Resources

These are some resources, sorted pedagogically, to get started with functional programming in Python:

  1. Functional Programming in Python by Dan Bader (videos): Nice low level introduction to map, filter and reduce functions. It shows also how easy it is to parallelise code in functional programming.
  2. Learning Data Science using Functional Python by Joel Grus (video): Nice talk on how to translate imperative code into functional code using Python. The title is misleading as data science is not the focus of the talk.
  3. Functional Programming in Python by David Mertz (short book): Nice and short book that explains the basic concepts of functional programming in Python using examples.
  4. Functional Programming HOWTO by A. M. Kuchling (tutorial): Overview of Fu
@FilippoBovo
FilippoBovo / python_decorator.md
Last active January 26, 2022 13:49
Decorator Example in Data Science

Decorator Example in Data Science

This example explains Python decorators in the context of data science. The example acts as a quick reminder, rather than a complete guide.

Consider a Pandas DataFrame about posts on a social media. The DataFrame, called posts, contains a column with the number of likes for each post.

post_id ... likes ...
1 ... 43 ...
2 ... 92 ...
@FilippoBovo
FilippoBovo / command_line_for_data_science.md
Last active April 9, 2019 16:16
Command Line uses for Data Science

Command Line uses for Data Science

The command line for data science is useful for:

  • Quickly check large CSV files
  • Checking data on a server, like in Google Cloud
  • Merging CSV files quickly
  • Replacing tabs with commas or similar formatting

Display CSV file in terminal

@FilippoBovo
FilippoBovo / communication_resources.md
Last active November 29, 2018 15:46
Communication Resources

Recommended references for Visualisation:

Recommended references for Design:

@FilippoBovo
FilippoBovo / sed_tutorial_by_example.sh
Last active November 15, 2018 16:15
Sed tutorial by example
# Sed tutorial by example
# Example: Substitute "cat" with "dog" in file.txt
sed 's/cat/dog/g' file.txt
# Here "s" stands for "substitute" and "g" for global. If "g" was not present, only the first occurrence would be substituted.
# The pattern after the first slash, /, is the pattern to look for and the pattern after the second slash is the pattern to substitute.
# Example: Substitute parentheses, (), in string 'Hello, (awesome) World!' with underscores, _.
echo 'Hello, (awesome) World!' | sed -E 's/(.*)\((.*)\)(.*)/\1_\2_\3/'
# Out: Hello, _awesome_ World!
@FilippoBovo
FilippoBovo / python_and_general_programming_resources.md
Last active July 26, 2018 13:47
Great Python and General Programming Resources