Skip to content

Instantly share code, notes, and snippets.

View asvnpr's full-sized avatar

Alejandro Vega asvnpr

  • Wovenware
  • Puerto Rico
View GitHub Profile
1.)
fun squareSum nil = 0
| squareSum(h::t) = h*h + squareSum(t);
how do tail recursive halp
2.)
@asvnpr
asvnpr / -
Created April 22, 2016 04:36
open List;
(* 1. Functions takes a list l and an int n ; Outputs l where the indexes are offset by n places *)
fun rotN(nil, n) = []
| rotN(l, 0) = l
| rotN(h::t, n:int) = if (n > 0) then
rotN([last(t)]@rev(tl(rev(h::t))),n-1)
else
@asvnpr
asvnpr / -
Created April 25, 2016 01:54
(* Alejandro Salvador Vega Nogales
801-13-7956
Prof. Koutis
CCOM-4029 *)
open List;
(* 1. Functions takes a list l and an int n ; Outputs l where the indexes are offset by n places
@asvnpr
asvnpr / -
Created April 25, 2016 02:16
(* Alejandro Salvador Vega Nogales
801-13-7956
Prof. Koutis
CCOM-4029 *)
open List;
(* 1. Functions takes a list l and an int n ; Outputs l where the indexes are offset by n places
@asvnpr
asvnpr / -
Created October 9, 2016 21:30
#! /bin/bash
#script for batch generating users for AECC's raspberry pi. All passwords are temporary and will need to be prompted for new passwords on first login
echo -ne "This script must be run as root!\nScript for creating users for AECC raspberry pi from a csv file.\nEnter path for csv file: "
read csv_file
#exit if not root
if [[ `id -u` != 0 ]]; then
echo "Must be root to run script"
@asvnpr
asvnpr / -
Created October 9, 2016 21:43
#! /bin/bash
#script for batch generating users for AECC's raspberry pi. All passwords are temporary and will need to be prompted for new passwords on first login
echo -ne "This script must be run as root!\nScript for creating users for AECC raspberry pi from a csv file.\nEnter path for csv file: "
read csv_file
#exit if not root
if [[ `id -u` != 0 ]]; then
echo "Must be root to run script"
@asvnpr
asvnpr / revDNAcompl.py
Last active February 1, 2017 04:21
reverse DNA compliment. no condition checking nor extra variables
#! /usr/bin/env python3
#from http://rosalind.info/problems/revc/
s = open("Downloads/rosalind_revc.txt", "r").read()
#added new line to dic since it's present in downloaded datasets
comp = {'A':'T', 'T':'A', 'C':'G', 'G':'C', '\n':''}
for c in s[::-1]:
print(comp[c], end='')
@asvnpr
asvnpr / sillyFibRabbits.py
Last active February 1, 2017 04:21
rabbits reproduce and stuff
#! /usr/bin/env python3
#from http://rosalind.info/problems/fib/
def rabi(n,m):
a = [1,1,2]
if (n < 4):
return a[n-1]
else:
for i in range(2, n):
a.append(a[i-1] - a[i-(m-1)])
@asvnpr
asvnpr / -
Created February 25, 2017 18:20
Error: Got Net::HTTPBadRequest from gist: {"message":"Problems parsing JSON","documentation_url":"https://developer.github.com/v3/gists/#create-a-gist"}
#! /usr/bin/env bash
# ask user for what to back up
read -p "Please enter the directory or file you wish to backup: " src
# compress and package
tar -czvf "$src-backup.tar.gz" "$src"
bak="$src-backup.tar.gz"
# ask where we're storing our backup
read -p "Enter directory or server where you want to store your backup: " dst
# check for remote destination
if echo "$dst" | grep -qe "(.*@.*\..*)" | grep -qe "^:$"; then dst+=':'; fi