You can use strace on a specific pid to figure out what a specific process is doing, e.g.:
strace -fp <pid>
You might see something like:
select(9, [3 5 8], [], [], {0, 999999}) = 0 (Timeout)
I spent a lot of time trying to find a pretty optimal (for me) setup for Clojure… at the same time I was trying to dive in and learn it. This is never optimal; you shouldn't be fighting the environment while trying to learn something.
I feel like I went through a lot of pain searching Google, StackOverflow, blogs, and other sites for random tidbits of information and instructions.
This is a comprehensive "what I learned and what I ended up doing" that will hopefully be of use to others and act as a journal for myself if I ever have to do it again. I want to be very step-by-step and explain what's happening (and why) at each step.
| #!/usr/bin/env ruby | |
| require "openssl" | |
| class BF < Struct.new(:key, :pad_with_spaces) | |
| def encrypt(str) | |
| cipher = OpenSSL::Cipher.new('bf-ecb').encrypt | |
| if pad_with_spaces | |
| str += " " until str.bytesize % 8 == 0 | |
| cipher.padding = 0 |
This is a summary of the "Learn You A Haskell" online book under http://learnyouahaskell.com/chapters.
| (ns katas.change-maker) | |
| (defn num-pairs | |
| "Returns all combinations of [x y] and (<= x y) where (= cents (+ x y))" | |
| [cents] | |
| (for [x (reverse (range 1 (inc (quot cents 2)))) ;; use the range from midpoint to 1 so that we walk the | |
| ;; shortest side of the tree first | |
| :let [y (- cents x)]] | |
| [x y])) |
| # | |
| # This is the way I configured my ruby environment on ArchLinux. | |
| # | |
| # I don't like the overhead of rvm, so I use chruby to switch between ruby versions. | |
| # So first you need to install chruby from source: | |
| # | |
| # https://github.com/postmodern/chruby#install | |
| # | |
| # To build ruby from source I use ruby-build, so after chruby we install ruby-build: | |
| # |
| total = 0 | |
| N = 300 | |
| start_time = time() | |
| for a in 0:(N - 1) | |
| for b in 0:(N - 1) | |
| for c in 0:(N - 1) | |
| if a^2 + b^2 == c^2 | |
| total = total + 1 |
| var styleFrame = document.createElement( 'iframe' ), | |
| stylesWaiting = [], | |
| styleFrameIsReady = false; | |
| styleFrame.setAttribute( 'style', | |
| 'visibility:hidden;position:absolute;top:0;left:0;width:1px;height:1px;' ); | |
| styleFrame.addEventListener( 'load', function () { | |
| var doc = styleFrame.contentDocument, | |
| html, i, l; |
| # activerecord-3.0.0/lib/active_record/connection_adapters/mysql_adapter.rb | |
| # Maps logical Rails types to MySQL-specific data types. | |
| def type_to_sql(type, limit = nil, precision = nil, scale = nil) | |
| return super unless type.to_s == 'integer' | |
| case limit | |
| when 1; 'tinyint' | |
| when 2; 'smallint' | |
| when 3; 'mediumint' | |
| when nil, 4, 11; 'int(11)' # compatibility with MySQL default |