This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # auto_cleanup.sh - simple lock system | |
| LOCKFILE="auto_cleanup.pid" | |
| # Check for another instance | |
| if [[ -e "$LOCKFILE" ]] && pgrep -F "$LOCKFILE" > /dev/null; then | |
| echo "there is another active instance" 1>&2 | |
| exit 1 | |
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // easter.js | |
| // Gauss Algorithm | |
| // https://pt.m.wikipedia.org/wiki/Cálculo_da_Páscoa | |
| // | |
| exports.easterSunday = function(year) { | |
| var X=0; | |
| var Y=0; | |
| if (year>=1582 && year<=1699){X = 22; Y = 2;} | |
| if (year>=1700 && year<=1799){X = 23; Y = 3;} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* cactorial.c - evaluates factorial */ | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| double recursive_factorial(int n) { | |
| if (n <= 0) | |
| return 0; | |
| if (1 == n) | |
| return 1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/python | |
| """Fibonacci sequence snippets""" | |
| # Python 2 compatibility | |
| from __future__ import division, print_function | |
| import argparse | |
| import math |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| oldest_file() | |
| { | |
| local dir="$1" | |
| [ -d "$dir" ] || dir="." | |
| find "$dir" -type f -printf '%T+ %p\n' | sort | awk '{print $2; exit}' | |
| } | |
| oldest_file "$@" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # shell date arithmetic | |
| secs() | |
| { | |
| TZ=UTC date --date="$1" '+%s' | |
| } | |
| date_diff() | |
| { |