Skip to content

Instantly share code, notes, and snippets.

@jameslyons
jameslyons / railfence.c
Last active August 29, 2015 13:56
C implementation of the railfence cipher
#include <stdlib.h>
#include <stdio.h>
void railfence_encipher(int key, const char *plaintext, char *ciphertext);
void railfence_decipher(int key, const char *ciphertext, char *plaintext);
int main(int argc, char *argv[]){
/* the string to encipher / decipher */
char *plaintext = "defendtheeastwallofthecastle";
/* allocate some space for results of enciphering/deciphering */
@jameslyons
jameslyons / porta.py
Created February 10, 2014 04:11
porta cipher in python
'''
implements porta cipher
Author: James Lyons
Created: 2012-06-27
'''
from .base import Cipher
####################################################################################
class Porta(Cipher):
def __init__(self,key='CODE'):
@jameslyons
jameslyons / arburg.jl
Created February 10, 2014 06:19
burg method of LPC computation
function arburg(x,p)
N = length(x)
P = zeros(1,p+1)
f = zeros(p+1,N)
b = zeros(p+1,N)
a = zeros(p,p)
# Initialisation
f[1,:] = x
@jameslyons
jameslyons / delastelle.py
Created February 10, 2014 07:26
delastelle cipher in python
from itertools import product
key = "EPSDUCVWYM ZLKXNBTFGORIJHAQ"
IND2L = dict(zip(list(product((1,2,3),repeat=3)),key))
L2IND = dict(zip(key,list(product((1,2,3),repeat=3))))
ptext = 'DEFEND THE EAST WALL OF THE CASTLE'
ctext = ""
for c in ptext:
@jameslyons
jameslyons / add_noise_to_NIST_files.m
Last active August 29, 2015 14:10
add_noise_to_NIST_files.m
SNR=40; % the SNR of white noise to apply to each file
path = '/home/james/databases/speech_db/timit_xxl_white/db/timit_full';
[status,result]=system(['find ',path,' -name "*.wav" | grep -v snr > ',path,'/timit_list.txt']);
listfilename = [path,'/timit_list.txt'];
filelist = fopen(listfilename);
wavname = fgetl(filelist);
count = 1;
while ischar(wavname),
@jameslyons
jameslyons / spectral_subtraction_demo.m
Created December 1, 2014 12:10
spectral subtraction demo in matlab
[sig fs] = read_NIST_file(filename); % read the input file, assume filename is supplied
NFFT = 1024;
WINLEN = 0.025; %frame length in ms
WINSTEP = 0.01;
frames = frame_sig(sig, WINLEN*fs, WINSTEP*fs, @hamming);
cspec = fft(frames,NFFT,2); % complex spectrum
pspec = abs(cspec).^2; % power spectrum of noisy signal
phase = angle(cspec);
% do spectral subtraction, produce modified_pspec
@jameslyons
jameslyons / pdb2fasta.py
Last active January 4, 2020 04:15
convert pdb file to fasta
import sys
if len(sys.argv) <= 1:
print 'usage: python pdb2fasta.py file.pdb > file.fasta'
exit()
input_file = open(sys.argv[1])
letters = {'ALA':'A','ARG':'R','ASN':'N','ASP':'D','CYS':'C','GLU':'E','GLN':'Q','GLY':'G','HIS':'H',
'ILE':'I','LEU':'L','LYS':'K','MET':'M','PHE':'F','PRO':'P','SER':'S','THR':'T','TRP':'W',
@jameslyons
jameslyons / f2routes.txt
Created December 18, 2014 09:45
second feynman cipher 40 routes
XUKEXWSLZJUAXUNKIGWFSOZRAWURORKXAOSLHROBXBTKCMUWDVPTFBLMKEFVWMUXTVTWUIDDJVZKBRMCWOIWYDXMLUFPVSHAGSVWUFWORCWUIDUJCNVTTBERTUNOJUZHVTWKORSVRZSVVFSQXOCMUWPYTRLGBMCYPOJCLRIYTVFCCMUWUFPOXCNMCIWMSKPXEDLYIQKDJWIWCJUMVRCJUMVRKXWURKPSEEIWZVXULEIOETOOFWKBIUXPXUGOWLFPWUSCH
XRFMTOUWLUKVLBCWCEKXWUEMUJIEAMFRUFUOXOUPTWPMEWSXVUPOVTSLTSNYXROLHVHOTCCOZRTAJRNJFJOWGULMUWUBUSZGCMKAXIVHBIVBXBDWVMWRIUTDUTCMKUNKJFWYSXXKCVWKPKWPIMZOOOPUXGUKRRJXRUWWBCSCEKGFDRWVLDPOSVMURRLSWOPCIZIYELZTWDSYIEFRFOUVTQIPABIJVVKWWWLWCFFDZUUMYNSCJVSRKDVQCWXCOEXTXMIUH
HCSUWPFLWOGUXPXUIBKWFOOTEOIELUXVZWIEESPKRUWXKRVMUJCRVMUJCWIWJDKQIYLDEXPKSMWICMNCXOPFUWUMCCFVTYIRLCJOPYCMBGLRTYPWUMCOXQSFVVSZRVSROKWTVHZUJONUTREBTTVNCJUDIUWCROWFUWVSGAHSVPFULMXDYWIOWCMRBKZVJDDIUWTVTXUMWVFEKMLBFTPVDWUMCKTBXBORHLSOAXKRORUWARZOSFWGIKNUXAUJZLSWXEKUX
HUIMXTXEOCXWCQVDKRSVJCSNYMUUZDFFCWLWWWKVVJIBAPIQTVUOFRFEIYSDWTZLEYIZICPOWSLRRUMVSOPDLVWRDFGKECSCBWWURXJRRKUGXUPOOOZMIPWKPKWVCKXXSYWFJKNUKMCTUDTUIRWMVWDBXBVIBHVIXAKMCGZSUBUWUMLUGWOJFJNRJATRZOCCTOHVHLORXYNSTLSTVOPUVXSWEMPWTPUOXOUFURFMAEIJUM
@jameslyons
jameslyons / create_iris_hdf5_files.m
Created August 20, 2015 07:16
matlab script for generating hdf5 data files for caffe
% load the dataset, this is built in to matlab
load fisheriris
% the data is ordered, we want to randomly select 100 points for train, 50
% for test. This part just generates a random list of array indices.
indices = randperm(150);
train_indices = indices(1:100);
test_indices = indices(101:end);
% meas contains the features, we use our random indices to select a subset
@jameslyons
jameslyons / iris_caffe_network.prototxt
Last active August 29, 2015 14:27
caffe network specification for single layer FF MLP on iris dataset.
name: "iris"
layer {
name: "data"
type: "HDF5Data"
top: "data"
top: "label"
include: {
phase: TRAIN
}
hdf5_data_param {