Skip to content

Instantly share code, notes, and snippets.

View charlesponti's full-sized avatar

Charles Ponti charlesponti

View GitHub Profile
@charlesponti
charlesponti / google_card.css
Created October 2, 2014 17:16
Google Card CSS
.card {
padding:1.5rem;
box-shadow:0 1px 2px #aaa;
background:white;
margin:0 1rem 1rem;
border-radius:3px;
user-select:none;
animation:fly-in-from-left .5s 1s ease both;
transform-origin:top left;
}
@charlesponti
charlesponti / bowerize.rb
Created August 17, 2014 22:32
Create Bower Package
puts '===================='
puts '======BOWERIZE======'
puts '===================='
puts '1. What\'s the name of your super awesome Bower package?'
@package_name = gets.chomp
puts '2. What is your GitHub username?'
@github_username = gets.chomp
# load libraries
require 'rubygems' rescue nil
require 'wirble'
#require 'json'
alias q exit
class Object
def local_methods
(methods - Object.instance_methods).sort
@charlesponti
charlesponti / Euler-16.rb
Last active December 17, 2015 04:08
Project Euler: Problem 16
def power_sum(base, expo)
num = base
2.upto(expo) { |i| num *= base }
sum = 0
num.to_s.split(//).each { |i| sum += i.to_i }
p sum
end
@charlesponti
charlesponti / Euler_3
Created May 7, 2013 16:58
Project Euler: Problem 3
def is_prime?(num)
2.upto(num-1) { |i| return false if ((num % i) == 0) }
true
end
def largest_prime(num)
primes = []
1.upto(num) { |i| primes << i if num % i == 0 && is_prime?(i) }
p primes.last
@charlesponti
charlesponti / Euler_1
Created May 7, 2013 14:05
Project Euler: Problem 1
def three_five(max)
nums = []
1.upto(max-1) { |i| nums << i if i % 3 == 0 || i % 5 == 0 }
p nums.reduce(:+)
end
@charlesponti
charlesponti / Euler_4
Created May 6, 2013 18:13
Project Euler: Problem 4
def is_palindrome?(num)
num == num.to_s.reverse.to_i ? true : false
end
def palindromatic
range = *(100..999)
results = []
range.each { |i| range.each { |x| results << (i*x) if is_palindrome?(i*x) } }
@charlesponti
charlesponti / Euler_5
Created May 6, 2013 18:11
Project Euler: Problem 5
def small_multiple(max)
range = *(1..max)
nums = []
results = []
range.each { |i| range.each { |x| nums << i*x } }
nums.each { |i|
range.each { |x|
answers = []
i % x == 0 ? answers << 'true' : answers << 'false'
results << i if !(answers.include? 'false')
@charlesponti
charlesponti / Euler_10
Created May 6, 2013 18:09
Project Euler: Problem 10
def is_prime?(num)
2.upto(num-1) { |i| return false if ((num % i) == 0) }
true
end
def sum_primes(max)
sum = 0
2.upto(max-1) { |i| sum += i if is_prime?(i) }
p sum
end
@charlesponti
charlesponti / Euler_8
Created May 6, 2013 18:09
Project Euler: Problem 8
def largest_product(num)
nums = num.to_s.split(//)
products = []
i = 5
0.upto(nums.length-1) { |i|
products << nums[i].to_i*nums[i-1].to_i*nums[i-2].to_i*nums[i-3].to_i*nums[i-4].to_i
}
p products.sort.last