I hereby claim:
- I am dmgarland on github.
- I am dmgarland (https://keybase.io/dmgarland) on keybase.
- I have a public key ASDXl6fdEW8xby6al3hPhXfusDPoB7dTXBhLlzNEqV7VYgo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
| # The decimal number, 585 = 10010010012 (binary), is palindromic in both bases. | |
| # Find the sum of all numbers, less than one million, which are palindromic in base 10 and base 2. | |
| # (Please note that the palindromic number, in either base, may not include leading 0's) | |
| # Naive approach - TODO: needs to avoid checking both base 2 and base 10 if base 10 isn't pallindromic | |
| def palindromic?(n, base = 10) | |
| numbers = n.to_s(base).split("") | |
| middle = numbers.length / 2.0 | |
| first_half = numbers.slice(0, middle.ceil) | |
| second_half = numbers.slice(middle.floor, numbers.length) |
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>Underscore example</title> | |
| <script src="underscore.js"></script> | |
| </head> | |
| <body> | |
| <div id="result"></div> |
| # encoding: utf-8 | |
| require 'rake/task' | |
| module Rake | |
| class Task | |
| alias :orig_execute :execute | |
| def execute(args=nil) | |
| orig_execute(args) |
| Country.create(iso: 'AF', name: 'Afghanistan', iso3: 'AFG') | |
| Country.create(iso: 'AL', name: 'Albania', iso3: 'ALB') | |
| Country.create(iso: 'DZ', name: 'Algeria', iso3: 'DZA') | |
| Country.create(iso: 'AS', name: 'American Samoa', iso3: 'ASM') | |
| Country.create(iso: 'AD', name: 'Andorra', iso3: 'AND') | |
| Country.create(iso: 'AO', name: 'Angola', iso3: 'AGO') | |
| Country.create(iso: 'AI', name: 'Anguilla', iso3: 'AIA') | |
| Country.create(iso: 'AG', name: 'Antigua and Barbuda', iso3: 'ATG') | |
| Country.create(iso: 'AR', name: 'Argentina', iso3: 'ARG') | |
| Country.create(iso: 'AM', name: 'Armenia', iso3: 'ARM') |
| <html> | |
| <head> | |
| <title>Underscore Howto</title> | |
| <script type="text/javascript" src="javascripts/jquery-2.1.1.js"></script> | |
| <script type="text/javascript" src="javascripts/underscore.js"></script> | |
| <script type="text/javascript" src="javascripts/my_amazing_javascript.js"></script> | |
| </head> | |
| <body> | |
| <h1>Underscore / JQuery practice</h1> |
| PadrinoBlog::App.controllers :authors do | |
| get :new do | |
| @author = Author.new | |
| erb :'authors/new' | |
| end | |
| post :create do | |
| @author = Author.new(params[:author]) |
| require 'sinatra' | |
| enable :sessions | |
| before do | |
| if request.path != '/login' && !session[:logged_in] | |
| redirect '/login' | |
| end | |
| end |
| class MyAmazingWebApp | |
| @@headers = { | |
| "Content-Type" => "text/html", | |
| "My-Amazing-Header" => "coolbeans" | |
| }.freeze | |
| def call(env) | |
| begin | |
| [200, @@headers, File.open("public#{env['PATH_INFO']}")] |
| require 'pry' | |
| require 'httparty' | |
| failed = [] | |
| File.open('urls.csv', 'r').each_with_index do |line, number| | |
| next if number == 0 | |
| path = line.split(",").first | |
| url = "http://localhost:9293#{path}" | |
| puts url |