Skip to content

Instantly share code, notes, and snippets.

@SavinaRoja
SavinaRoja / scrambler.py
Last active July 15, 2023 20:33
Scrambler - is a small commandline script made to randomize file names. It stores a log of all the file renaming events which it later uses to unscramble the names.
#!/usr/bin/env python
"""
Scrambler is a small commandline script made to randomize file names. It stores
a log of all the file renaming events which it later uses to unscramble the
names. This script may not guard against intentional dishonesty, but it does
protect one from unconscious bias.
All of the matching options may be used simultaneously, but only files which
satisfy each restriction will be scrambled (the intersection of each match set).
@SavinaRoja
SavinaRoja / flac2mp3.sh
Created February 10, 2012 22:43
How I convert my FLAC to mp3 in linux
#!/bin/bash
# Converts all flac files in a folder into mp3s, plus the id3 tag
# Requires flac, metaflac, lame, id3v2
for a in *
do
# Check the file is a flac file
if [[ "$a" =~ flac$ ]]
then
@SavinaRoja
SavinaRoja / seq2fa.py
Created February 15, 2012 22:24
A quick converter of some .seq files to .fa
import os
import os.path
def main():
outdir = 'FASTAs'
if not os.path.isdir(outdir):
os.mkdir(outdir)
for s in os.listdir(os.getcwd()):
r, e = os.path.splitext(s)
if e.lower() == '.seq':
@SavinaRoja
SavinaRoja / seqs2fa.py
Created February 15, 2012 23:37
Another .seq to .fa converter, except this one dumps all the data into a single .fa file with multiple entries.
import os
import os.path
def main():
outdir = 'FASTA'
if not os.path.isdir(outdir):
os.mkdir(outdir)
with open(os.path.join(outdir, 'bundled_seqs.fa'), 'w') as output:
for s in os.listdir(os.getcwd()):
r, e = os.path.splitext(s)
@SavinaRoja
SavinaRoja / probdist.py
Created February 16, 2012 19:09
Putting down some concepts and an implementation of certain probability distributions.
#Probability Distributions implemented interactively.
#An exercise in python mathematics and statistical methods
#I am developing this to further my understanding of bio-informatics by using
#a base-up approach.
import math
import random
class Binomial:
'''The binomial distribution has two possible outcomes. which may be
@SavinaRoja
SavinaRoja / PE_15.py
Created February 17, 2012 01:44
Solutions to Project Euler #15 using Pascal's Triangle and The Binomial Coefficient
#Problem 15 from Project Euler
#
#Here are solutions by Paul Barton
#
#The problem outlines a 2 dimensional space of 21 nodes by 21 nodes, or 20 boxes
#by 20 boxes. It asks how many distinct paths may be taken without backtracking.
#
#It appears that backtracking is counter-intuitively defined as moving away from
#the end point, or in a negative fashion, rather than visiting the same node
#twice. This is makes it way the hell simpler...
@SavinaRoja
SavinaRoja / PE18.py
Created February 18, 2012 03:27
A solution to Project Euler #18.
#Problem 18 from Project Euler
#Solution by Paul Barton
#
#The problem presents us with a triangle, which I represent as a list of lists
#in the code the below. Though this problem *may* be brute forced, I would like
#to do this problem elegantly the first time through, as it is merely a scaled
#down version of one which is not brute-forceable later on (#67).
#Thus we need a method that scales well.
#
#I observe that the algorithm has only limited need for memory. Each point has
@SavinaRoja
SavinaRoja / PE_19.py
Created February 22, 2012 00:13
Problem 19 from Project Euler
#Problem 19 from Project Euler
#Solution by Paul Barton
#
#You are given the following information, but you may prefer to do some research
#for yourself.
#
# * 1 Jan 1900 was a Monday.
# * Thirty days has September,
# April, June and November.
# All the rest have thirty-one,
@SavinaRoja
SavinaRoja / canvas_gravity.html
Created March 16, 2012 21:10
A non-deterministic simulation of gravity using HTML5's canvas.
<!DOCTYPE HTML>
<html>
<head>
<script type="text/javascript">
//I'd like to credit Eric Rowell at http://www.html5canvastutorials.com/ for eir instruction
window.requestAnimFrame = (function(callback){
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
@SavinaRoja
SavinaRoja / PE_25.c
Created April 5, 2012 18:17
Problem 25 from Project Euler in C
/*Problem 25 from Project Euler
Solution by Paul Barton
Here is the text of the problem:
The Fibonacci sequence is defined by the recurrence relation:
Fn = Fn1 + Fn2, where F1 = 1 and F2 = 1.
Hence the first 12 terms will be:
F1 = 1