Skip to content

Instantly share code, notes, and snippets.

@davidbella
davidbella / gist:4014209
Created November 4, 2012 22:53
CueUp/greplin Level 1 - Longest Palindrome Substring
use strict;
use warnings;
open my $inputFH, '<', 'block.txt';
while (my $line = <$inputFH>) {
chomp $line;
my @letters = split(//, $line);
# For every letter in the string
for (my $letter = 0; $letter < scalar @letters; $letter++) {
@davidbella
davidbella / gist:4014229
Created November 4, 2012 22:59
CueUp/greplin Level 2 - Fibonacci Primes
use strict;
use warnings;
my $lowerBound = shift;
my ($oldValue, $value) = fib(1, 1);
while ($value < $lowerBound ? 1 : 0 || !isPrime($value)) {
print $oldValue, ", ", $value, "\n";
($oldValue, $value) = fib($oldValue, $value);
@davidbella
davidbella / gist:4014245
Created November 4, 2012 23:02
CueUp/greplin Level 3 - Subset Sums
use strict;
use warnings;
use Math::Combinatorics;
my @numbers = (3, 4, 9, 14, 15, 19, 28, 37, 47, 50, 54, 56, 59, 61, 70, 73, 78, 81, 92, 95, 97, 99);
my $total = 0;
for (my $sum = 0; $sum < scalar @numbers; $sum++) {
next if ($sum < 3);
@davidbella
davidbella / gist:6679856
Created September 24, 2013 03:02
Alien Sandwich
1. Place the plate in front of you, such that the concave face of the plate is pointing up
2a. The loaf of bread is the plastic packaging containing the soft spongelike rectangle. The bread is already sliced, meaning there will be several individual slices within the packaging.
2b. Hold the loaf of bread such that the packaging is pointing up so that the bread does not fall out.
2c. Remove any plastic pieces that are keeping the plastic sealed around the loaf of bread.
2d. Open the plastic packaging and remove two slices of bread from the top of the loaf.
2e. Optionally reseal the packaging on the loaf of bread
3. The knife is the long, thin, metal object. This will be used to transfer both the peanut butter and jelly onto the bread slices. More on this soon.
3a. The knife has two ends. One end is to be held in your hand, while the other end will be used to make contact with the peanut butter or jelly while transferring it to the bread.
@davidbella
davidbella / gist:6684214
Last active December 23, 2015 19:39
Testing GFM
def some_method
  puts "Hello"
end

So it looks like "Markdown" on GitHub is GitHub Flavored Markdown - how presumptious!

  • Checking out task lists
  • Pretty cool - Gist has some level of auto-complete
@davidbella
davidbella / gist:6684502
Created September 24, 2013 13:11
My Profile
Name: David Bella
Github: http://github.com/davidbella
Blog: http://davidbella.github.io
Tagline:
Profile Picture:
Treehouse Account: http://teamtreehouse.com/davidbella
CoderWall Account: https://coderwall.com/davidbella
CodeSchool Account: http://www.codeschool.com/users/davidbella
Favorite Websites:
Previous Work Experience: Client Data Integration Engineer at FactSet
CREATE TABLE wizards(
name TEXT,
age INTEGER
);
@davidbella
davidbella / 02_create_artists.sql
Created September 25, 2013 03:55
SQL: Simple create, alter, and drop tables
CREATE TABLE artists(
name TEXT,
album_count INTEGER,
song_count INTEGER,
worth_in_mil REAL
);
@davidbella
davidbella / fizzbuzz.rb
Last active December 23, 2015 23:19
Ruby: Simple FizzBuzz
fizz = []
buzz = []
fizzbuzz = []
(1..50).each do |number|
print "#{number}: "
if (number % 3 == 0 && number % 5 == 0)
puts "FizzBuzz"
fizzbuzz << number
@davidbella
davidbella / part6.first_program.rb
Created September 26, 2013 03:28
Ruby: Exercise in working with arithmetic
# Given:
# 5 songs of the following lengths in seconds
# 223,215,378,324,254
# Goals:
# Assign the length set to variables
# Calculate the Total Length of the Playlists
# Express the Length in Minutes
# Average Song Length in Minutes