Skip to content

Instantly share code, notes, and snippets.

View bbuckley's full-sized avatar

Brian K. Buckley bbuckley

View GitHub Profile
:foo / :bar # => [:foo, :bar]
:foo / :bar / :fizz # => [:foo, :bar, :fizz]
:foo / :bar / :foo # => [:foo, :bar]
:foo / :bar / :fizz / :bizz # => [:foo, :bar, :fizz, :bizz]
[12,3,4,5].map{|x| x * 2}.inspect
include Enumerable
def each
return Enumerator.new(self,:each) unless block_given?
yield 1
yield 2
end
puts each.inject(:+).inspect
puts each{|x| x * x}.inject(:+).inspect
# By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6^(th) prime is 13.
#
# What is the 10001^(st) prime number?
require 'mathn'
puts Prime.instance.each.tap{ |x| 10000.times{ x.next} }.next #104743
@bbuckley
bbuckley / album.rb
Created October 25, 2009 14:42 — forked from rklemme/album.rb
require 'yaml'
Track = Struct.new :title, :duration
# An Album represents an audio medium which has title,
# interpret, a pause duration between tracks and a list
# of individual tracks.
class Album
attr_reader :title, :interpret, :pause
#! ruby19
require 'date'
class EndlessEnum
include Enumerable
def initialize(x, method = :succ)
@x = x
@method = method
$(document).ready(function(){
var searchIDs = $('input:checked').map(function(){
return $(this).val();
});
console.log(searchIDs.get());
$('input').on('change',function(){
@bbuckley
bbuckley / index.html
Created February 7, 2017 02:15 — forked from anonymous/index.html
React Calculator
<div id="wrapper">
<div id="app"></div>
</div>
@bbuckley
bbuckley / Main.elm
Created October 2, 2017 00:17 — forked from anonymous/Main.elm
pipeline
module Main exposing (main)
import Html exposing (Html, text)
a =
[ 28, 6, 34, -99 ]
main : Html msg
@bbuckley
bbuckley / Main.elm
Created October 2, 2017 00:29 — forked from anonymous/Main.elm
pipeline
module Main exposing (main)
import Html exposing (Html, text)
a =
[ 2, 28, 6, 34, -9 ]
tuple =