text:
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require 'socket'
require 'fileutils'
PhusionPassenger.require_passenger_lib 'analytics_logger'
PhusionPassenger.require_passenger_lib 'utils/tmpdir'

module PhusionPassenger

shared_examples_for "analytics logging extensions for Rails" do
	before :each do
		@logging_agent_password = "1234"
		@dump_file = "#{Utils.passenger_tmpdir}/log.txt"
		@agent_pid, @socket_filename, @socket_address = spawn_logging_agent(@dump_file,
			@logging_agent_password)
		@options = {
			"analytics" => true,
			"logging_agent_address" => @socket_address,
			"logging_agent_username" => "logging",
			"logging_agent_password" => "1234",
			"node_name" => "localhost",
			"app_group_name" => "foobar"
		}
	end

	after :each do
		@connection.close if @connection && @connection.closed?
		Process.kill('KILL', @agent_pid)
		Process.waitpid(@agent_pid)
	end

	def send_request_to_app(headers)
		headers = {
			"PASSENGER_TXN_ID"     => "1234-abcd"
		}.merge(headers)
		return perform_request(headers)
	end

	def read_log
		return File.read(@dump_file)
	end

	def base64(data)
		return [data].pack('m').gsub("\n", "")
	end

	it "doesn't install analytics logging extensions if analytics logging is turned off" do
		@options.delete("analytics")
		File.write("#{@stub.app_root}/app/controllers/foo_controller.rb", %Q{
			class FooController < ActionController::Base
				def index
					File.open("out.txt", "w") do |f|
						f.write(request.env["PASSENGER_ANALYTICS_WEB_LOG"].class.to_s)
					end
					render :nothing => true
				end
			end
		})
		start!(@options)
		send_request_to_app("PATH_INFO" => "/foo")
		eventually(5) do
			filename = "#{@stub.app_root}/out.txt"
			File.exist?(filename) && File.read(filename) == "NilClass"
		end
	end

	it "logs the controller and action name" do
		File.write("#{@stub.app_root}/app/controllers/foo_controller.rb", %Q{
			class FooController < ActionController::Base
				def index
					render :nothing => true
				end
			end
		})
		start!(@options)
		send_request_to_app("PATH_INFO" => "/foo")
		eventually(5) do
			flush_logging_agent(@logging_agent_password, @socket_address)
			log = read_log
			log.include?("Controller action: FooController#index\n")
		end
	end

	it "logs uncaught exceptions in controller actions" do
		File.write("#{@stub.app_root}/app/controllers/crash_controller.rb", %Q{
			class CrashController < ActionController::Base
				def index
					raise "something went wrong"
				end
			end
		})
		start!(@options)
		send_request_to_app("PATH_INFO" => "/crash")
		eventually(5) do
			flush_logging_agent(@logging_agent_password, @socket_address)
			log = read_log
			log.include?("Request transaction ID: 1234-abcd\n") &&
				log.include?("Message: " + base64("something went wrong")) &&
				log.include?("Class: RuntimeError") &&
				log.include?("Backtrace: ") &&
				log.include?("Controller action: CrashController#index")
		end
	end

	it "logs ActionController benchmarks" do
		File.write("#{@stub.app_root}/app/controllers/foo_controller.rb", %Q{
			class FooController < ActionController::Base
				def index
					if respond_to?(:benchmark, true)
						benchmark("hello") do
						end
					else
						ActionController::Base.benchmark("hello") do
						end
					end
					render :nothing => true
				end
			end
		})
		start!(@options)
		send_request_to_app("PATH_INFO" => "/foo")
		eventually(5) do
			flush_logging_agent(@logging_agent_password, @socket_address)
			log = read_log
			log.include?('BEGIN: BENCHMARK: hello') &&
				log.include?('END: BENCHMARK: hello')
		end
	end

	it "logs ActionView benchmarks" do
		File.write("#{@stub.app_root}/app/controllers/foo_controller.rb", %Q{
			class FooController < ActionController::Base
			end
		})
		FileUtils.mkdir_p("#{@stub.app_root}/app/views/foo")
		File.write("#{@stub.app_root}/app/views/foo/index.html.erb", %Q{
			<% benchmark("hello") do %>
			<% end %>
		})
		start!(@options)
		send_request_to_app("PATH_INFO" => "/foo")
		eventually(5) do
			flush_logging_agent(@logging_agent_password, @socket_address)
			log = read_log
			log.include?('BEGIN: BENCHMARK: hello') &&
				log.include?('END: BENCHMARK: hello')
		end
	end

	it "logs successful SQL queries" do
		File.write("#{@stub.app_root}/app/controllers/foo_controller.rb", %Q{
			class FooController < ActionController::Base
				def index
					db = ActiveRecord::Base.connection
					db.execute("CREATE TABLE foobar (id INT)")
					db.execute("INSERT INTO foobar VALUES (1)")
					render :nothing => true
				end
			end
		})
		start!(@options.merge("active_record" => true))
		send_request_to_app("PATH_INFO" => "/foo")
		extra_info_regex = Regexp.escape(base64("SQL\nCREATE TABLE foobar (id INT)"))
		eventually(5) do
			flush_logging_agent(@logging_agent_password, @socket_address)
			log = read_log
			log =~ /BEGIN: DB BENCHMARK: .* \(.*\) #{extra_info_regex}$/ &&
				log =~ /END: DB BENCHMARK: .* \(.*\)$/
		end
	end

	it "applies event preprocessor to log events" do
		File.write("#{@stub.app_root}/app/controllers/foo_controller.rb", %Q{
			class FooController < ActionController::Base
				def index
					db = ActiveRecord::Base.connection
					db.execute("CREATE TABLE foobar (id INT)--secret")
					db.execute("INSERT INTO foobar VALUES (1)")
					render :nothing => true
				end
			end
		})
		start!(@options.merge("active_record" => true))
		send_request_to_app("PATH_INFO" => "/foo")
		extra_info_regex = Regexp.escape(base64("SQL\nCREATE TABLE foobar (id INT)--PASSWORD"))
		eventually(5) do
			flush_logging_agent(@logging_agent_password, @socket_address)
			log = read_log
			log =~ /BEGIN: DB BENCHMARK: .* \(.*\) #{extra_info_regex}$/ &&
				log =~ /END: DB BENCHMARK: .* \(.*\)$/
		end
	end

	it "logs failed SQL queries" do
		File.write("#{@stub.app_root}/app/controllers/foo_controller.rb", %Q{
			class FooController < ActionController::Base
				def index
					db = ActiveRecord::Base.connection
					db.execute("INVALID QUERY")
					render :nothing => true
				end
			end
		})
		start!(@options.merge("active_record" => true))
		send_request_to_app("PATH_INFO" => "/foo")
		extra_info_regex = Regexp.escape(base64("SQL\nINVALID QUERY"))
		if rails_version >= '3.0'
			pending do
				eventually(5) do
					log = read_log
					log =~ /BEGIN: DB BENCHMARK: .* \(.*\) #{extra_info_regex}$/ &&
						log =~ /FAIL: DB BENCHMARK: .* \(.*\)$/
				end
			end
		else
			eventually(5) do
				flush_logging_agent(@logging_agent_password, @socket_address)
				log = read_log
				log =~ /BEGIN: DB BENCHMARK: .* \(.*\) #{extra_info_regex}$/ &&
					log =~ /FAIL: DB BENCHMARK: .* \(.*\)$/
			end
		end
	end

	it "logs controller processing time of successful actions" do
		File.write("#{@stub.app_root}/app/controllers/foo_controller.rb", %Q{
			class FooController < ActionController::Base
				def index
					render :nothing => true
				end
			end
		})
		start!(@options)
		send_request_to_app("PATH_INFO" => "/foo")
		eventually(5) do
			flush_logging_agent(@logging_agent_password, @socket_address)
			log = read_log
			log.include?("BEGIN: framework request processing") &&
				log.include?("END: framework request processing")
		end
	end

	it "logs controller processing time of failed actions" do
		File.write("#{@stub.app_root}/app/controllers/foo_controller.rb", %Q{
			class FooController < ActionController::Base
				def index
					raise "crash"
				end
			end
		})
		start!(@options)
		send_request_to_app("PATH_INFO" => "/foo")
		eventually(5) do
			flush_logging_agent(@logging_agent_password, @socket_address)
			log = read_log
			log.include?("BEGIN: framework request processing") &&
				log.include?("FAIL: framework request processing")
		end
	end

	it "logs view rendering time of successful actions" do
		File.write("#{@stub.app_root}/app/controllers/foo_controller.rb", %Q{
			class FooController < ActionController::Base
				def index
				end
			end
		})
		FileUtils.mkdir_p("#{@stub.app_root}/app/views/foo")
		File.write("#{@stub.app_root}/app/views/foo/index.html.erb", %Q{
			hello world
		})
		start!(@options)
		send_request_to_app("PATH_INFO" => "/foo")
		eventually(5) do
			flush_logging_agent(@logging_agent_password, @socket_address)
			log = read_log
			log.include?("BEGIN: view rendering") &&
				log.include?("END: view rendering") &&
				log =~ /View rendering time: \d+$/
		end
	end

	it "logs view rendering time of failed actions" do
		File.write("#{@stub.app_root}/app/controllers/foo_controller.rb", %Q{
			class FooController < ActionController::Base
				def index
				end
			end
		})
		FileUtils.mkdir_p("#{@stub.app_root}/app/views/foo")
		File.write("#{@stub.app_root}/app/views/foo/index.html.erb", %Q{
			<% raise "crash!" %>
		})
		start!(@options)
		send_request_to_app("PATH_INFO" => "/foo")
		eventually(5) do
			flush_logging_agent(@logging_agent_password, @socket_address)
			log = read_log
			log.include?("BEGIN: view rendering") &&
				log.include?("FAIL: view rendering")
		end
	end

	it "logs cache hits" do
		if rails_version >= '2.1'
			File.write("#{@stub.app_root}/app/controllers/foo_controller.rb", %Q{
				class FooController < ActionController::Base
					def index
						Rails.cache.write("key1", "foo")
						Rails.cache.write("key2", "foo")
						Rails.cache.write("key3", "foo")
						Rails.cache.read("key1")
						Rails.cache.fetch("key2")
						Rails.cache.fetch("key3") { "bar" }
						render :text => 'ok'
					end
				end
			})
			start!(@options)
			send_request_to_app("PATH_INFO" => "/foo")
			eventually(5) do
				flush_logging_agent(@logging_agent_password, @socket_address)
				log = read_log
				log.include?("Cache hit: key1") &&
					log.include?("Cache hit: key2") &&
					log.include?("Cache hit: key3")
			end
		end
	end

	it "logs cache misses" do
		if rails_version >= '2.1'
			File.write("#{@stub.app_root}/app/controllers/foo_controller.rb", %Q{
				class FooController < ActionController::Base
					def index
						Rails.cache.read("key1")
						Rails.cache.fetch("key2")
						Rails.cache.fetch("key3") { "bar" }
						render :text => 'ok'
					end
				end
			})
			start!(@options)
			send_request_to_app("PATH_INFO" => "/foo")
			eventually(5) do
				flush_logging_agent(@logging_agent_password, @socket_address)
				log = read_log
				log.include?("Cache miss: key1") &&
					log.include?("Cache miss: key2") &&
					log =~ /Cache miss \(\d+\): key3/
			end
		end
	end
end

end # module PhusionPassenger

redpajama_set_name: RedPajamaGithub


Hanne Ørstavik's The Blue Room (translated by Deborah Dawkin, review copy courtesy of the publisher) is a psychological novel set in two different places. The first is the blue room of the title, the bedroom of Norwegian student Johanne, where the unfortunate young woman wakes one morning only to find that she can't open the door – because it's been locked from the outside.
The Blue Room is an excellent book, and after one reading it's up there with my favourite Peirene books (probably my favourite of the ones I've read in English). A fascinating read, it's also frustrating at times, as the writer takes us on a trip through the psyche of a damaged, submissive young woman. In following Johanne's thoughts of the past two weeks, we are given a look at the problem of family relationships and the dangers arising when family members become that little bit too close.
This simple plea is key to her personality, revealing a longing to be dominated, a wholly submissive nature which is in danger of taking over her life. The relationship with Ivar, which, for most people, would be a joyous time, is overshadowed at times by her depressing thoughts. Her mind is full of disturbing images, her fantasies, nightmares, of what might happen if she allows herself to get swept away.
If you're wondering where this all comes from, you don't have to look very far. A recent Twitter meme was asking for examples of bad parents in literature, and Johanne's Mum would be right up there. As well as showing us a fragile young woman, Ørstavik also creates a portrait of the mother as a highly damaging influence, a controlling, manipulative shadow hanging over poor Johanne's life. This is a mother-daughter relationship which goes a little too far (as shown by some quite disturbing scenes on the toilet..).
With Johanne reliant on her mother for accommodation and living expenses if she's ever going to achieve her plan of building up a psychology practice (an idea which someone else planted in her mind…), she feels as if she's using her mother, a feeling which leads to guilt. In truth, though, it's most definitely the mother who is abusing her position.
Fantastic review, Tony. I agree with everything you've expressed so brilliantly here. Except one comment: how are you so sure the mother locked her in?
Brilliant review, Tony. The Blue Room is such an intriguing book and open to different interpretations/readings. I noticed the recurring references to Johanne's back pain (and discomfort in her head and eyebrows). I'm convinced there's a significance to it, but I couldn't decipher the meaning behind this motif.
Sounds interesting. Your review made me think this might be interesting to read in conjunction with The Yellow Wallpaper. (Have you read it/ It's really just a long short story and available freely online?) Another to watch out for..
I wondered whether the physical pain was a manifestation of her mental torture. Often it's a sign of stress, isn't it? So I've been considering whether it's symptomatic of the pressure she's placing herself under, attempting to live up to ideals she developed through church and her morher's expectations, even though it's evident (particularly in the case of her mother) that these expectations are hypocritical.
Ah yes, I could go with those interpretations. As Naomi has said elsewhere, we need a spoiler-free forum for the discussion of this book (and others)..


text:
Building Giants
Mega Mountain Tunnel
As engineers race to build a brand-new train tunnel beneath the Alps, they use cutting-edge tech and the latest construction methods to build the world's longest underground railroad in some of the most dangerous conditions on earth.
Super Skyscraper Chicago
In Chicago, engineers race against the clock to build a supertall skyscraper that will be one of the most luxurious towers in the world. They must battle fierce Arctic-like winds and extreme heights to add this new centerpiece to the famous skyline.
Les tries to survive seven days in the Northern reaches of Baffin Island
Survivorman
Les Stroud is airdropped onto a snow-covered peak in the Canadian Rockies.
Winter Plane Crash
Les attempts to survive a week in the harsh wilderness of northern Ontario.
Les attempts to survive in the inhospitable canyonlands of Utah.
Les Stroud attempts to survive a week off the coast of Belize.
Les attempts to survive in the Sonoran Desert with just a bottle of water.
Boreal Forest (Autumn)
Les must survive a week in the Boreal Forest with just a handful of food.
Georgia Swamp
Les spends seven nights in the swamplands of the Altamaha River Basin.
Lee is tasked with surviving while marooned off Costa Rica's Osa Peninsula.
Norwegian Mountain Survival 1
Les strands himself in the Norwegian mountains to survive for ten days.
Les Stroud is determined to survive the Norwegian mountains.
Mexican Desert Island Part 1
Les is shipwrecked on the island of Tiburon -- part of the Sonoran Desert.
Les avoids packs of wild desert animals on the Mexican island of Tiburon.
Les is left to survive in inhospitable Tierra del Fuego, Argentina.
Frigate Island
Les is stranded on Frigate Island -- an active volcano chain.

redpajama_set_name: RedPajamaCommonCrawl


text:
Categories Here Comes Honey Boo Boo | Toddlers & Tiaras
Anderson Cooper finds a way to make Toddlers & Tiaras even creepier
16 Feb. 2012 | 8:53 pm
The kids and parents who appear on TLC's Toddlers & Tiaras are disturbing enough, but former The Mole host Anderson Cooper has found a way to make them even more creepy: by dressing up the moms just like their daughters.
They'll receive makeovers as part of his daytime talk show Friday, and at first that seemed like a way to just validate and celebrate this insanity. But a preview of the episode highlights how painful some of those modifications are, like weaves and corsets, so if they're doing it to torture the parents, I'm okay with that.
The results are, of course, horrifying. Be forewarned: Honey Boo Boo's mom June is, well–sometimes, you just need to look at the photo.
One World drama equals lowest ratings ever for a Survivor premiere
The Voice will return in the fall with all four judges


I must say that these conversations as of late have been very stimulating, all this talk about living and not living in places of perceived danger and felt danger. I have some last words to say before I head out on a two-week hiatus in a couple days.
I am not trying to con-vice anyone and especially Shane of my position for I know that if I were to seek to do that I would be trying to convince someone to Wess' truth not God's. However, I do not see myself as one who is misled by the Spirit and thus I feel it necessary to exegete my view further, with a greater depth and clarity so that there may be peace and understanding of how I see (and how I ultimately feel the Spirit has led me to see) these things discussed.
First to my friend (and I mean that with the utmost sincerity) Shane, In one of your recent posts you said, "it seems like some Christians want to frown upon my wife and I for moving out of a not so nice neighborhood (which I'm just going to call the ghetto) because too many Christians are moving out." I must respond in an offer of peace, that I would much rather you think of my comments as first coming from friend and then coming from a Christian. The reason for the splitting of these hairs are that often to say a "Christian thinks this or that about me" equates "He or she is judging me." I have added comments first as a friend who feels that I have room to make comments in a constructive way and further, and in the hopes to create dialog that will be beneficial to all for I know that as we seek to have clear and fair dialogue with one another the Spirit is able to teach us all. This was a basic premise that underlined our Monday Night Bible study back in the day, we believed that everyone had a right to speak, that is those who are of faith in Christ, because we all have the spirit of God within us. So take this as a peace offering.
Secondly, I think as people of faith we ought to be intentional about becoming more aware of those who are underprivileged, oppressed or just down and out. This is why the word "Ghetto" makes my spine tingle, and why the connotations with that word are even worse. What we I think we mean (and I mean we because I am guilty of it too) when we say Ghetto is something more discriminatory, and often classist or racist. What I mean is that Ghetto has a very negative and hurtful connotation, hurtful to God who is the God of the oppressed (and Ghettos are often times homes of the oppressed – this is a basic historical point). The Minor Prophets in the Old Testament, and Psalms such as 130, and 136 tell us that God intentionally seeks justice for the poor. If this is true then we ought to as Christians as God, how can we be active in helping him in his pursuit.
Notice I said "His pursuit" this is because to minister to and with those who are poor and unlovely (and often times dangerous) is not our pursuit as human beings, it is not the thing that we choose naturally, that is why it is so hard to find social workers who have worked in the field for a long time (and if you can – ask them is they still enjoy their job). Working with the unloved is the business of the church. No one argues this point; it is just how we interpret the unloved that makes this tricky.
Who are the unloved? I think there are many in every race and class that are unloved. I think that we ought to have the church serving all peoples, and loving all. But the problem comes when everyone wants to love, serve and live in specific suburban areas. That is to say, there are too many people being called to the Suburbs (if that is what it is) and not enough being called to the city. Is God unaware of the needs in places like skid row in downtown LA where 20,000 people are homeless every night (In America)? And Skid row is just blocks wide and a not many deep. There are not many churches down there, and the ones that are really need help surviving because there are little resources. But In Pasadena where the city seeks to be a "Utopia" (this is literally what council members have said they want that suburb to be) there are churches (and wealthy ones at that) all over the place. Some of the largest and most influential churches in the country are here. So I ask who are the Unloved? And what are we doing to put our lives on the line to love them.
Isn't this what Jesus did? He said if you seek to save your life you will lose it, but if you seek to lose your life you will save it. Did he also actually live this way? Shane brought up a good point about the times when Christ fled when his life was in danger. Christ did flee, but it tells us three things about Christ: 1) he had a certain appointment with death that could not be interrupted or maligned for his appointment would change the course of history (my death certainly is not anywhere close to this category); 2) If Christ fled from danger more than once that assumes that he continued to go back to dangerous areas; 3) and/or Christ was not in dangerous places because poor people and unloved people are not dangerous to him, rather danger came to find him – that is those who sought to kill him watched for opportunities to do such, such as the chief priests, Pharisees and Herod (Mark 2).
I agree with my brother who stated that it is funny for one to say that Christians are leaving the city, when in reality most people want to flee to the suburbs. The clarification is that it is mainly the whites who are the ones leaving, this is an actual statistical fact and in the anthropology and sociology books you will find the exact term "White-Flight" to explain the phenomena that rules much of white Americans and that includes the church. Why are they running…fear.
But the God of Upside-down values says, "Fear not for I am with you," and Ephesians 1 talks of the triumphant power we have in Christ, Paul talks in Gal. that "I no longer live, But Christ in me" (meaning he has forfeited all of his "rights" to God, and in Phil. he say "to live is Christ and to die is gain (drawing a paradox of equal value between life and death)." Finally we know that James Jesus' brother told his audience that "religion that God our Father accepts as pure and faultless is this: to look after orphans and widows in their distress…" Who are the orphaned and widowed in our day, the powerless, the hopeless, the unloved and rejected?
Finally I think that we should as Christians at least at Prayerfully "what is my part in helping to serve the poor and unwanted." Because this mindset is a much more active response to the problem than noticing it and wanting to do something about it, but yet making no move. This Our fault in downtown Canton, we loved living on 8th street, and knew a couple of people that lived on our street but neither of us were pro-active in being Christ to our neighbors and that is where we messed up. Because all God asks us to do is to be His people to those around us – to pro-actively love and serve whoever may come across our paths.
I guess I think often about Luke 4:18-19 and what Jesus said he came to do, it was his inaugural speech for his ministry, here are the things that were on his agenda that is pretty powerful and I want to have that same Christ-centered agenda because it was good enough for him. Secondly Matthew 11:4-6 Kind of tells what Jesus had accomplished that far into his ministry, which were the things he said he was gonna do "…the good news is preached to the poor…" they had to be preached to because many of them had never heard before, because they were not welcome in the synagogues etc.