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 / github-backup.sh
Created April 20, 2017 15:38
Poor-man Bash hack to backup all of a user's GitHub repositories.
#!/bin/sh
username=
curl -s https://api.github.com/users/$username/repos | jq -r '.[].git_url' | while read git_url
do
repo_name=$(basename $git_url .git)
echo Backing up $repo_name
git clone -q $git_url 2> /dev/null || (
cd $repo_name
@realeroberto
realeroberto / up.sh
Last active November 16, 2016 10:43 — forked from ldante86/up.sh
Get uptime and second conversion
#!/bin/bash -
PROGRAM="${0##*/}"
IFS="."
for i in $(cat /proc/uptime)
do
UPTIME=$i
break
done
@realeroberto
realeroberto / self-evaluating.tcl
Created November 11, 2016 10:51
A self-evaluating Tcl proc.
proc x {} { set y "x" }
# let's try it...
#
# % x
# x
# % [x]
# x
# % [[x]]
# x
@realeroberto
realeroberto / e-power-series-gui.tcl
Created November 11, 2016 10:01
Approximate the value of e using the power series expansion (with GUI).
#
# approximate the value of e using the power series expansion (with GUI)
#
# see http://www.tkdocs.com/tutorial/firstexample.html
#
package require Tk
@realeroberto
realeroberto / GrayCode.ps1
Created November 3, 2016 14:03
Convert an integer to its Gray-code representation.
#
# convert an integer to its Gray-code representation
#
Add-Type -TypeDefinition @'
public class shift {
public static int lshift(int x, int count) { return x << count; }
public static int rshift(int x, int count) { return x >> count; }
}
'@
@realeroberto
realeroberto / delete-tranches.sql
Last active September 15, 2018 22:12
PL/SQL trick: delete rows in tranches.
--
-- delete rows in tranches
--
-- inspired by the discussion at http://kr.forums.oracle.com/forums/thread.jspa?threadID=365130
--
set serveroutput on
DECLARE
ln_DelSize NUMBER := 500;
@realeroberto
realeroberto / factorial.sml
Created February 6, 2016 14:57
My first attempt at "coding" in Standard ML.
(* factorial *)
(* my first Standard ML ``program'' *)
(* see the excellent tutorial at *)
(* http://www.soc.napier.ac.uk/course-notes/sml/manual.html *)
fun factorial(1) = 1
| factorial(n) = n * factorial(n-1);
@realeroberto
realeroberto / factorial.d
Last active February 6, 2016 14:32
Tail-recursive factorial() in D.
import std.stdio;
ulong
factorial(int n)
{
if(n < 2)
return 1;
else
return n * factorial(n - 1);
}
@realeroberto
realeroberto / insertion-sort.c
Created February 6, 2016 14:28
A naive implementation of Insertion Sort in C.
/*
* a naive implementation of Insertion Sort in C.
*/
void
insertion_sort(int *array, int array_len)
{
int i;
for (i = 1; i < array_len; i++) {
@realeroberto
realeroberto / factorial.scm
Last active February 6, 2016 14:21
Tail-recursive factorial in Scheme.
;
; Tail-recursive factorial in Scheme.
;
(define (factorial n)
(if (= n 1)
1
(* n (factorial(- n 1)))))