Skip to content

Instantly share code, notes, and snippets.

@cdemyanovich
cdemyanovich / euler.clj
Last active December 29, 2015 02:49
Solutions to 3 Project Euler problems for Clojure 101 at 8th Light.
(ns euler.core)
(defn multiple-of-3-or-5? [n] (or (= 0 (mod n 3)) (= 0 (mod n 5))))
(defn sum-of-multiples-of-3-or-5-below [n]
(apply + (filter multiple-of-3-or-5? (range 1 n))))
(defn fibs []
(map first (iterate (fn [[a b]] [b (+ a b)]) [1N 1N])))
@cdemyanovich
cdemyanovich / brew_install_python_output.txt
Created October 23, 2012 18:42
Output from brew install python on OS X 10.8.2
$ brew install python
==> Downloading http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tar.bz2
Already downloaded: /Library/Caches/Homebrew/python-2.7.3.tar.bz2
==> ./configure --prefix=/usr/local/Cellar/python/2.7.3 --enable-ipv6 --datarootdir=/usr/local/Cellar/python/2.7.3/share --datadir=/usr/local/Cellar/python/2.7.3/share --enable-framework=/usr/local/Cellar/python/2.7.3/Frameworks --witho
==> make
==> make install PYTHONAPPSDIR=/usr/local/Cellar/python/2.7.3
==> make frameworkinstallextras PYTHONAPPSDIR=/usr/local/Cellar/python/2.7.3/share/python
==> Downloading http://pypi.python.org/packages/source/d/distribute/distribute-0.6.28.tar.gz
Already downloaded: /Library/Caches/Homebrew/distribute-0.6.28.tar.gz
==> /usr/local/Cellar/python/2.7.3/bin/python -s setup.py --no-user-cfg install --force --verbose --install-lib=/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages --install-scripts=/usr/l
@cdemyanovich
cdemyanovich / application.rb
Created April 7, 2012 14:14
Test Rails 3 application configuration
require File.expand_path('../boot', __FILE__)
require 'rails/all'
if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
Bundler.require(*Rails.groups(:assets => %w(development test)))
# If you want your assets lazily compiled in production, use this line
# Bundler.require(:default, :assets, Rails.env)
end
@cdemyanovich
cdemyanovich / menu.html
Created October 21, 2011 03:26
8LU: Brown Bag Lunch Truck menu
<!doctype html>
<html>
<head>
<title>Menu | Brown Bag Lunch Truck</title>
</head>
<body>
<header>
<h1>Brown Bag Lunch Truck</h1>
<h2>truck menu</h2>
require 'spec_helper'
class SomeRecord
attr_accessor :password
attr_reader :errors
def initialize(attrs = {})
@password = attrs.delete(:password)
@errors = ActiveModel::Errors.new(self)
end
@cdemyanovich
cdemyanovich / rakefile.rb
Created May 6, 2011 15:43
Porting build to use Sprout
require 'rubygems'
require 'bundler'
require 'bundler/setup'
require 'rake/clean'
require 'flashsdk'
require 'asunit4'
namespace :as2 do
sprout "as2"
class Order < ActiveRecord::Base
has_many :line_items, :dependent => :destroy, :order => "position"
accepts_nested_attributes_for :line_items, :allow_destroy => true, :reject_if => lambda { |attributes| attributes["amount"].blank? }
validates_associated :line_items
private
def validate
@cdemyanovich
cdemyanovich / gist:729740
Created December 6, 2010 02:29
failure installing lein-search plugin
$ lein plugin install lein-search 0.3.3
Downloading: org/clojure/clojure/1.1.0/clojure-1.1.0.pom from central
Downloading: org/clojure/clojure-contrib/1.1.0/clojure-contrib-1.1.0.pom from central
Downloading: org/clojure/clojure-contrib/1.1.0/clojure-contrib-1.1.0.pom from clojure
Transferring 1K from clojure
Downloading: org/clojure/clojure/1.1.0/clojure-1.1.0.jar from central
Downloading: org/clojure/clojure-contrib/1.1.0/clojure-contrib-1.1.0.jar from central
Downloading: org/clojure/clojure-contrib/1.1.0/clojure-contrib-1.1.0.jar from clojure
Transferring 3215K from clojure
Copying 2 files to /var/folders/Qc/QcHVL6pTFVmL3sdeOxoGwk+++TI/-Tmp-/lein-c20dc40b-5eb0-4755-ae00-3165d3787009/lib
@cdemyanovich
cdemyanovich / gist:712118
Created November 23, 2010 17:05
Server error on Ajax request; Rails 2.3.5 on Glassfish gem 1.0.3dev on JRuby 1.5.3
Nov 23, 2010 4:22:16 PM sun.reflect.GeneratedMethodAccessor1 invoke
INFO: /!\ FAILSAFE /!\ Tue Nov 23 16:22:16 +0000 2010
Status: 500 Internal Server Error
undefined method `merge' for nil:NilClass
/root/deployments/bank/current/localgems/gems/activesupport-2.3.5/lib/active_support/whiny_nil.rb:52:in `method_missing'
/root/deployments/bank/current/localgems/gems/actionpack-2.3.5/lib/action_controller/request.rb:389:in `parameters'
/root/deployments/bank/current/localgems/gems/actionpack-2.3.5/lib/action_controller/base.rb:1288:in `assign_shortcuts'
/root/deployments/bank/current/localgems/gems/actionpack-2.3.5/lib/action_controller/base.rb:527:in `process'
/root/deployments/bank/current/localgems/gems/actionpack-2.3.5/lib/action_controller/filters.rb:606:in `process_with_filters'
/root/deployments/bank/current/localgems/gems/haml-2.2.20/lib/sass/plugin/rails.rb:20:in `process'
$ script/generate migrtion drop_start_date_from_enrollment
JRuby limited openssl loaded. http://jruby.org/openssl
gem install jruby-openssl for full support.
exists db/migrate
create db/migrate/20100802182614_drop_start_date_from_enrollment.rb