Skip to content

Instantly share code, notes, and snippets.

View realeroberto's full-sized avatar
💭
Trust your journey.

Roberto Reale realeroberto

💭
Trust your journey.
View GitHub Profile
@realeroberto
realeroberto / gist:69a484740ce66f494aa4ecf991df5ec3
Created May 6, 2021 19:23
Remove unnecessary executable bit from a Git repository
# the order of the two statements is crucial (of course)
find \( -path ./.git -prune -false -o -executable \) -a -type f -exec git update-index --chmod=-x {} \;
find \( -path ./.git -prune -false -o -executable \) -a -type f -exec chmod -x \{} \;
@realeroberto
realeroberto / guardian-by-keyword.sh
Created March 2, 2021 06:29
Download summaries of all Guardian articles for a given keyword
#!/bin/sh
# Download summaries of all Guardian articles for a given keyword
TAG=${1:-covid}
APIKEY=test
APIROOT=https://content.guardianapis.com
# LOOP 1: get all tags containing $TAG
@realeroberto
realeroberto / pnrr2wordcloud
Created February 10, 2021 23:19
Generates a wordcloud from the most recent version of the Italian National recovery and resilience plan
#!/bin/sh
# pnrr2wordcloud
#
# Generates a wordcloud from the most recent version of the Italian National
# recovery and resilience plan (Piano Nazionale di Ripresa e Resilienza - PNRR)
#
# Author: Roberto Reale <roberto@reale.me>
# Last updated: 2021-02-11
@realeroberto
realeroberto / wallis.tcl
Created September 15, 2018 22:28
Approximate PI with the aid of Wallis' product
#!/usr/bin/tclsh
#
# approximate PI with the aid of Wallis' product
#
proc wallis {{n 1000000}} {
set value 1.0
set i 1
@realeroberto
realeroberto / chebyshev.tcl
Created September 15, 2018 22:27
Recursively calculate Chebyshev polynomials
#!/usr/bin/tclsh
# we need Tcl 8.5 for lrepeat to be defined
package require Tcl 8.5
#
# recursively calculate Chebyshev polynomials
#
# (see http://en.wikipedia.org/wiki/Chebyshev_polynomials)
#
@realeroberto
realeroberto / e-power-series.tcl
Created September 15, 2018 22:26
Approximate the value of e using the power series expansion
#!/usr/bin/tclsh
#
# approximate e using the power series expansion
#
proc approx_e {{n 20}} {
set value 1
set factorial 1
set i 1

Keybase proof

I hereby claim:

  • I am reale on github.
  • I am reale (https://keybase.io/reale) on keybase.
  • I have a public key ASC7prRw88qck0mao3uzp2TtsM1ZxhzzIMwGA62Z1s7llAo

To claim this, I am signing this object:

BEGIN
FOR cur_rec IN (SELECT object_name, object_type
FROM user_objects
WHERE object_type IN
('TABLE',
'VIEW',
'PACKAGE',
'PROCEDURE',
'FUNCTION',
'SEQUENCE',
@realeroberto
realeroberto / make-tarball.sh
Created February 16, 2018 16:56
Create a tarball from inside a folder
#!/bin/sh
# create a tarball from inside a folder
dirname=$(cat PROJECT)-$(cat VERSION)
tarball=${dirname}.tar.gz
# avoid tar's error message ``file changed as we read it''
touch "$tarball"
tar cfz "$tarball" \
@realeroberto
realeroberto / perm2octal.sh
Created February 16, 2018 16:51
Convert a file mode string into the octal value
#!/bin/bash
# Convert a file mode string (e.g., -rw-rw-r--) into the octal value
function perm2octal()
{
local perm=${1:1} # remove first char (the file type)
res=$(echo "$perm" | sed 's/[^-]/1/g; s/-/0/g')
res=$(echo "ibase=2; obase=8; $res" | bc)