Skip to content

Instantly share code, notes, and snippets.

🌴

Ryan Seys ryanseys

🌴
Block or report user

Report or block ryanseys

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ryanseys
ryanseys / reverse.py
Created Jan 17, 2013
Reverse a string in Python
View reverse.py
def reverse(s):
return s[::-1]
@ryanseys
ryanseys / fib_r.rb
Created Jan 20, 2013
Recursive Fibonacci solution
View fib_r.rb
def fib_r(n)
if(n <= 1)
return 1
else
return fib(n-1) + fib(n-2)
end
end
@ryanseys
ryanseys / fib_i.rb
Created Jan 20, 2013
Iterative Fibonacci Solution
View fib_i.rb
def fib_i(n)
result = p1 = p2 = 1;
if(n > 1)
for i in 1..n
result = p1 + p2
p2 = p1
p1 = result
end
end
return result
@ryanseys
ryanseys / print_s.c
Created Jan 20, 2013
Print string using no loops in C
View print_s.c
#include <stdio.h>
void print_s(const char * s) {
if(*s != 0) {
putchar(*s);
print_s(s+1);
}
}
int main() {
@ryanseys
ryanseys / print_s_r.c
Created Jan 20, 2013
Print a reverse string using no loops in C
View print_s_r.c
#include <stdio.h>
void print_s_r(const char * s) {
if(*s != 0) {
print_s_r(s+1);
putchar(*s);
}
}
int main() {
@ryanseys
ryanseys / play_mp3.rb
Created Apr 3, 2013
Play MP3 file in terminal using Ruby
View play_mp3.rb
pid = fork{ exec 'afplay', "song.mp3" } # on mac osx
@ryanseys
ryanseys / LinkEntry.java
Created Apr 5, 2013
Queue Data Structure in Java
View LinkEntry.java
/**
* "LinkEntry" class.
* This is an entry (or node) for a linked list containing an
* object of type E as the entry's data.
* @author Ryan Seys
*
* @param <E> the type of element which makes up the link entry.
*/
public class LinkEntry<E> {
protected E element; // The entry's data.
@ryanseys
ryanseys / FixLyricsWorkingWithSelection.scpt
Last active Dec 15, 2015
Remove excess strings from lyrics which are inserted and generated from the app "Get Lyrical".
View FixLyricsWorkingWithSelection.scpt
(* This is a script made by Ryan Seys to remove the excess strings from lyrics that are inserted and generated from the application "Get Lyrical". It properly removes the Title and Artist from the start of the Lyrics, and the text "branding" that Get Lyrical inserts to all the lyrics it fetches. Usage: Select the songs that you would like to clean in iTunes, then run the script.*)
on trim_line(this_text, trim_chars, trim_indicator)
-- 0 = beginning, 1 = end, 2 = both
set x to the length of the trim_chars
-- TRIM BEGINNING
if the trim_indicator is in {0, 2} then
repeat while this_text begins with the trim_chars
try
set this_text to characters (x + 1) thru -1 of this_text as string
@ryanseys
ryanseys / passer_rating.py
Created Apr 6, 2013
Calculates the Passer Rating (passer efficiency or pass efficiency) of a player given some variables. Use at own risk, old-as-fuck code here.
View passer_rating.py
# This Python application will calculate the passer rating
# (passer efficiency or pass efficiency) given the five required variables.
#
# Variables to be used as values are defined below. Set to strings so input
# can be anything. Later the strings will be converted to numbers, given
# they pass a series of error checking tests.
COMP = "null"
ATT = "null"
YARDS = "null"
@ryanseys
ryanseys / fac_rec.js
Created Apr 21, 2013
Recursive Factorial in JavaScript
View fac_rec.js
function fac_rec(n) {
if(n <= 1) return 1;
else return n * fac_rec(n-1);
}
You can’t perform that action at this time.