This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn ^:private progress-input-stream | |
[^java.io.InputStream input-stream size] | |
(let [total-read (atom 0)] | |
(proxy [java.io.InputStream] [] | |
(available [] | |
(.available input-stream)) | |
(close [] | |
(.close input-stream)) | |
(read | |
([] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Movie < ActiveRecord::Base | |
def self.all_ratings | |
# debugger | |
find_by_sql("SELECT DISTINCT rating FROM movies").map(&:rating) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ApplicationHelper | |
def highlight_tag_if(condition, tag, &block) | |
if condition | |
content_tag tag, :class => 'hilite', &block | |
else | |
content_tag tag, &block | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# PURPOSE: | |
# The purpose of this script is to generate a list of commands to delete unused access rules from a | |
# Cisco PIX or ASA firewall. This script is appropriate if you use the RedSeal application: | |
# http://www.redsealnetworks.com. Currently the results are printed to the screen only. | |
# | |
# INSTRUCTIONS: | |
# When you want to clean up unused rules on a firewall. Use the RedSeal application to run a cleanup: | |
# Tools > Manage Device Cleanup (Alt+T, C). When finished, export the results as a CSV file. Don't | |
# forget to include the .CSV extension. Run this script and type the name of the file with the |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Earlier attempt | |
(defn factorial [n] | |
(loop [n n | |
result n] | |
(if (<= n 1) | |
1 | |
result) | |
(recur (dec n) (* result (dec n))))) | |
;; Working so far |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn is-even? [n] | |
(if (= n 0) | |
(not false) | |
(recur (is-even? (dec n))))) | |
(meditations | |
"Recursion ends with a base case" | |
(= true (is-even? 0)) | |
"And starts by moving toward that base case" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def chop(int, array_of_int) | |
return -1 if array_of_int.empty? | |
@max ||= array_of_int.size - 1 | |
@min ||= 0 | |
@mid ||= @max / 2 + @min | |
return @mid if int == array_of_int[@mid] | |
return -1 if @mid == @max |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!!! 5 | |
%html | |
%head | |
%title TESTAPP | |
= stylesheet_link_tag "application" | |
= javascript_include_tag "application", "registration" | |
= csrf_meta_tag | |
%body | |
%header | |
%h1#logo |
NewerOlder