tag:blogger.com,1999:blog-45488174463530682042024-02-06T21:12:54.284-06:00Better Orange Than DeadFo guck yourself.Better Orange Than Deadhttp://www.blogger.com/profile/06115750575805432531noreply@blogger.comBlogger163125tag:blogger.com,1999:blog-4548817446353068204.post-62351977036384064432014-06-25T20:25:00.000-05:002014-06-25T20:25:04.299-05:00LocomotiveCMS Multiple Select/Checkbox Many to ManyOK so I fumbled around with this for quite a while in LocomotiveCMS. To get a public submission form to work with a set of checkboxes (and presumably with a multiple select) use a form element like this:<br />
<br />
<br />
<pre>%input.resource-selection{type: :checkbox, value: '{{ resource._slug }}', name: 'content[interests][]', id: "{{ resource._slug }}" }><{{ resource.name }}
</pre>
<br />
(That is inside of a liquid iterating loop, with a resource being a single entry in resources)
The relationship on the model for public submissions is linked to the model that contains a list of options, via many-to-many
so if you have a resources (in our case, requestable resources)
<br />
<br />
<pre>- messages:
label: Messages
type: many_to_many
required: false
unique: false
localized: false
class_name: messages
ui_enabled: true
</pre>
asd<br />
and on the other side (messages, the field was called interests, as in "what I'm interested in")<br />
<br />
<br />
<pre>- interests:
label: Interests
type: many_to_many
hint: A description of the field for the editors
required: false
unique: false
localized: false
class_name: requestable_resources
ui_enabled: true
</pre>
<br />
Hope this helps someone. Drop a note if you want me to try clarify something.<br />
<br />
~NicBetter Orange Than Deadhttp://www.blogger.com/profile/06115750575805432531noreply@blogger.com0tag:blogger.com,1999:blog-4548817446353068204.post-83513868144663119222013-08-28T16:58:00.003-05:002013-08-28T16:58:45.242-05:00Rails routing namespace removal, and avoiding catastropheSo I am working on this project. The project is one big application, with two sub applications. One of the sub applications was axed in this context, but the other wasn't. They had namespaces (say /first and /second)<br />
<br />
it was requested to remove the namespace and put all of the controllers in the root namespace.<br />
<br />
Panic ensued.<br />
<br />
I came up with a quick solution, instead of re-writing a bunch of controllers, helpers JS and views:<br />
<br />
Thankfully I had used path helpers in most cases, except javascript. I went back, and put helpers in all of those places where I had been lazy, and used an actual path. Then, when my routes file had<br />
<br />
<pre><code>namespace :one do</code></pre>
<pre><code> resources :things, :stuff</code></pre>
<pre><code>end</code></pre>
<br />
I changed it to (not inside any namespace)<br />
<br />
<pre><code>scope module: 'one', as: 'one' do</code></pre>
<pre><code> resources :things, :stuff</code></pre>
<pre><code>end</code></pre>
<div class="p1">
<br /></div>
<div class="p1">
<span class="s2">The module option sets the module prefix to be used in controllers (so I didn't have to change those), and the as option put the prefixes on the path helpers (so they'd still work even though it was all in root namespace). </span></div>
<div class="p1">
<span class="s2"><br /></span></div>
<div class="p1">
<span class="s2">Upon further investigation, I found that the namespace route helper actually just uses scope like this</span></div>
<div class="p1">
<span class="s2"><br /></span></div>
<div class="p1">
<pre><code>
<span class="s2">namespace :something do</span>
</code></pre>
<pre> XYZ</pre>
<pre>end</pre>
<br />
converts to
<span class="s2"><br /></span></div>
<div class="p1">
<pre><code>
<span class="s2">scope module: :something, path: :something, as: :something do</span></code></pre>
<pre><code><span class="s2"> XYZ</span></code></pre>
<pre><code><span class="s2">end</span></code></pre>
</div>
<div class="p1">
</div>
<div class="p1">
<span class="s2">So there. If you ever need a wholesale change, you can drop the namespace helper in routes, and use scope to change the path without renaming a bunch of stuff. </span></div>
<div class="p1">
<span class="s2"><br /></span></div>
<div class="p1">
<span class="s2">Hopefully this saves someone the headache I was looking at when the change was proposed.</span></div>
<div class="p1">
<span class="s2"><br /></span></div>
<div class="p1">
<span class="s2">~Nic</span></div>
Better Orange Than Deadhttp://www.blogger.com/profile/06115750575805432531noreply@blogger.com3tag:blogger.com,1999:blog-4548817446353068204.post-14738545401881229682013-04-28T22:09:00.000-05:002014-06-26T07:25:11.404-05:00Rails Single Table Inheritance With ActiveAdmin and NamespacesSo I stumbled with this for hours, working on a monkey patch for Inherited Resources, finally giving up. Basically, if you use STI with ActiveAdmin, don't use module namespaces. It breaks the shit out of inherited resources.. IH can't deal with the "Name::Class" ::'s, it just borks.. the monkey patch I was working on was to resolve the error when IH tries to use the model name as an instance variable like @Name::Class, which ruby is not interested in trying to do.<br />
<br />
<br />
So, moral of the story: Don't use namespaced (with modules) STI models with AA, or IH.<br />
~Nic<br />
<br />
UPDATE: I was sent this from an anonymous commenter. Excellent tip:<br />
<br />
<blockquote class="tr_bq">
This actually works if you create a dummy class for your Namespaced model. For example do something like this: ActiveAdmin.register Parent::Child, as "MyClass". And then create a dummy model called MyClass as class MyClass < Parent::Child. This works.</blockquote>
UPDATE: I was sent this as well by another commenter:<br />
<blockquote class="tr_bq">
This ugly shit works:<br />ActiveAdmin.register ::MyModule::Base, :as => 'MyModel'<br /><br /><br />without Dummy models </blockquote>
Better Orange Than Deadhttp://www.blogger.com/profile/06115750575805432531noreply@blogger.com5tag:blogger.com,1999:blog-4548817446353068204.post-41790485751614038002012-01-16T18:46:00.000-06:002012-01-16T18:46:02.698-06:00Holy shit I've got a RESTful connection to a non-rails app with Rails... only a
billion goddamn overrides of ActiveResource every GOD DAMN time I use
the thing:<br />
<br />
This finder produces: http://...spex...net/service/rest/catalog?appId=xxxxxx&method=getVersion<br />
<br />
<code>EtilizeProduct.find(:catalog, :params => {:appId => 'xxxxxx', :method => 'getVersion'})</code><br />
<pre><code> </code></pre>
Reports: 200 OK 157 (199.0ms) (Version 3.0) XML<br />
<br />
I had to override element_path in ActiveResource::Base to do this:<br />
<pre><code></code>
<code> class << self
def element_path(id, prefix_options = {}, query_options = nil)
prefix_options, query_options = split_options(prefix_options) if query_options.nil?
"#{prefix(prefix_options)}/#{id}#{query_string(query_options)}"
end
end</code></pre>
<pre>
</pre>
<pre>#Idea from: http://www.quarkruby.com/2008/3/11/consume-non-rails-style-rest-apis</pre>
This is here in case I need to do this again. <br />
<br />
~NicBetter Orange Than Deadhttp://www.blogger.com/profile/06115750575805432531noreply@blogger.com0tag:blogger.com,1999:blog-4548817446353068204.post-8609283058876333952011-12-21T16:11:00.001-06:002011-12-21T16:13:09.648-06:00Klobuchar & Franken: Pull your heads out of your asses.SOPA isn't part of a war on piracy, it's part of the civilization-old push against the free exchange of information.<br />
<br />
Don't think for one fucking second that because the internet exists as
it does now -- as a place where you can say anything you want, blog
about whatever, edit Wikipedia -- that it will continue to exist that
way in the future. <br />
<br />
I will quote Leary out of context: <br />
"Throughout human history, as our species has faced the frightening,
terrorizing fact that we do not know who we are, or where we are going
in this ocean of chaos, it has been the authorities — the political, the
religious, the educational authorities — who attempted to comfort us by
giving us order, rules, regulations, informing — forming in our minds —
their view of reality. To think for yourself you must question
authority and learn how to put yourself in a state of vulnerable
open-mindedness, chaotic, confused vulnerability to inform yourself."<br />
<br />
The SOPA (and Protect IP) legislation, (and those who are also opposed
to net neutrality) are another incarnation of that authority that wishes
to crush the human spirit "for its own good". <br />
<br />
<b>This anti-human legislation has support from people on BOTH sides of the aisle, including Klobuchar and Franken. <span style="background-color: #ffd966; color: black;">They can both go fuck themselves</span>.</b><br />
<br />
This is serious shit. Capitol Hill Switchboard: 202-224-3121<br />
<br />
~NicBetter Orange Than Deadhttp://www.blogger.com/profile/06115750575805432531noreply@blogger.com0tag:blogger.com,1999:blog-4548817446353068204.post-67165209260015813032011-12-04T15:10:00.001-06:002011-12-04T15:13:47.461-06:00Steeeeeeeeeeeeeerike oneI <strike>hate</strike> love it when people use strike-through. It <strike>was cool the first thousand times </strike>conveys originality. <strike>Go fuck yourself</strike> Have a nice day.<br />
<br />
(This isn't directed at anyone in particular, so if you're offended <strike>you're an idiot</strike> I'm sorry.<br />
<br />
~NicBetter Orange Than Deadhttp://www.blogger.com/profile/06115750575805432531noreply@blogger.com0tag:blogger.com,1999:blog-4548817446353068204.post-35212076331932347292011-11-25T20:27:00.001-06:002011-11-25T20:57:38.211-06:00May the greed be with youAnd also with you.<br />
<br />
Being that today is black Friday, and I've been reading AdBusters for the last decade, and there's an occupy movement happening, I decided to think on greed a bit today. I am a fucking concern troll. That said, let's see the <a href="http://dictionary.reference.com/browse/greed">definition </a><br />
<blockquote class="tr_bq">
<div class="luna-Ent">
excessive or rapacious desire, especially for wealth or possessions.</div>
</blockquote>
Shit. That's not very helpful. How about <a href="http://dictionary.reference.com/browse/excessive">excessive </a><br />
<blockquote class="tr_bq">
<div class="luna-Ent">
going beyond the usual, necessary, or proper limit or degree; characterized by excess: excessive charges; excessive criticism.</div>
</blockquote>
Well piss. It seems that we're going to end up on a loop of looking up subjective labels. And... I'll be damned: that's the problem. There's nothing inherently wrong/bad with/about greed. There's not. The real problem is with propaganda. If I say:<br />
<blockquote class="tr_bq">
I want to squeeze every ounce of money out of my employees, working them to death. To do this I will lobby against the minimum wage under the banner of worker freedom. I will work to convince people that the 40 hour work week is oppressive -- they could work more if only I didn't have to pay them more -- and should be abolished. I will forgo basic safety precautions, as they are expensive.. and everyone knows they shouldn't put a stroller on an escalator, why do I need to spend the $50 to put a sign there anyhow?</blockquote>
and call it anything other than greed, I am lying. It is true that the definition is subjective - that excessive is "in the eye of the beholder". But this subjectivity is being used against all of us. The "Reasonable Person" has been killed (by Mammon himself, no doubt), and we've let everyone get away with it. I think it is specifically because "greed is not inherently bad" that we forget that it is also not inherently good. Because of this, we find ourselves allowing our conservative friends/enemies/whatevers to escape us when we don't say:<br />
<blockquote class="tr_bq">
...perhaps Laffer was originally right, but how is cutting taxes on the rich while maintaining tax levels, or increasing them on the middle class and poor not an example of wealthy greed?</blockquote>
Right. That's fucking right. It's the same answer I give to "well, if you don't believe in God, what reason do you have to live"? I say "any reason to live has no bearing on the existence of God". <br />
<br />
But anyhow, we've got to stop allowing people to say that "big corporations are not greedy, they're just doing what they do", and the like. While greed is not inherently bad/evil, neither is infanticide (it sounds pretty fucking lame that I would say that, but ontology is pretty brutal). I think we can all agree that infanticide is unacceptable, can't we agree that at least SOME greed is also unacceptable?<br />
<br />
~NicBetter Orange Than Deadhttp://www.blogger.com/profile/06115750575805432531noreply@blogger.com0tag:blogger.com,1999:blog-4548817446353068204.post-29258834267955160562011-11-14T14:01:00.001-06:002011-12-16T16:07:02.115-06:00OCI8 with Phusion Passenger/Rails 3.1 on Freebsd 8 ** UPDATEDThis has been one of the most trying things I've done.. My employer uses a backend database of Oracle 9i, or the like. I have to connect to it with Rails to simplify some queries, using oci8. <br />
<br />
Ruby 1.9.2 also.<br />
<br />
Install the freebsd linux-oracle-instantclient-* ports<br />
follow directions here: http://ruby-oci8.rubyforge.org/en/InstallForFullClient.html<br />
(You will have to install both oracle ports)<br />
<br />
Punch something that won't break your hand, but will be hard enough to relieve some anger<br />
<br />
Use gems, NOT the ports collection for the gems..<br />
<br />
gem install ruby-oci8 (Using the freebsd port fucks everything up)<br />
gem install activerecord-oracle_enhanced-adapter<br />
<br />
You will have to modify /usr/local/lib/ruby/site_ruby/oci8.rb to make line 38 know where your .so file is. replace site_ruby with your ruby install path. I use site_ruby because of rvm (Another goddamn hassle to set up)<br />
<br />
This got me up and running, but I am not sure if these steps are in order, or if I did anything else. This was a fucking hassle and I wouldn't recommend doing it.. but if you have to, and you get stuck, post a comment and I'll see if I can't help you figure out your problem<br />
<br />
~Nic<br />
<br />
ETA:<br />
<br />
A ruby wrapper to set this bullshit is necessary as well:<br />
<br />
#!/bin/sh<br />
export LD_LIBRARY_PATH=/usr/local/oracle8-client/lib<br />
export TNS_ADMIN=/usr/local/oracle8-client/network/admin<br />
export NLS_LANG=AMERICAN_AMERICA.UTF8<br />
export ORACLE_HOME=/usr/local/oracle8-client<br />
exec "/usr/local/bin/ruby" "$@"<br />
<br />
ETA2:<br />
<br />
This only works on fucking i386. If you have to use OCI8 on FreeBSD, it's only going to work on i386. I tried and tried, and no x64.Better Orange Than Deadhttp://www.blogger.com/profile/06115750575805432531noreply@blogger.com1tag:blogger.com,1999:blog-4548817446353068204.post-37912320328524706672011-11-08T19:35:00.002-06:002011-11-08T19:55:15.320-06:00God hates cigarettes?"I don't really care what people do in their private lives," said
62-year-old communications consultant George Werl of Minneapolis. But he
said marriage should be limited to heterosexual couples because it was
designed to protect the children of those unions. (<a href="http://www.startribune.com/politics/statelocal/133406223.html">via</a>)<br />
<br />
What he means to say is: <br />
"I don't really care what people do in their private lives. I really
care what people do in their private lives". It's a Rick James moment.<br />
<br />
This amendment vote is a year away. We must all fight it. Fuck the
spin, it's homophobic, bigoted and simple minded. Marriage is a dying
arbitrary patriarchal institution anyhow, not to mention the SIBS study
has all but proven that biological relationship between parents and
children has no impact positive or negative on the child's "success" in
life (but it's OK to use a child to force a mother or father into
"calming down"/"growing up")<br />
<br />
These are bogus issues designed to pit us against each other and ignore
the reality that we're all being screwed ... by the 1% (Thanks
adbusters for making that so succinct). If you REALLY FUCKING DON'T
CARE what people do in their private lives, [then] SHUT THE FUCK UP.<br />
<br />
Amen brother.<br />
<br />
~Nic<br />
<br />
**edit: than? Idiot.Better Orange Than Deadhttp://www.blogger.com/profile/06115750575805432531noreply@blogger.com0tag:blogger.com,1999:blog-4548817446353068204.post-48202008045155663782011-11-02T21:30:00.001-05:002011-11-02T21:39:35.399-05:00Let there be plightI am severely troubled by how the fox spin machine is portraying the
occupy movement (but not surprised). It's something I am afraid has
been picking up steam for a while: "college education is unnecessary" (I
know, this isn't news). Of course, these people don't believe that's
true for anyone in their families.. <br />
<br />
I remember something that I heard on public radio years ago that
solidified my stance of pro-education for everyone (regardless of
costs).. some jacknut Eichten had on his program said "Now Gary, what do
I care if my car mechanic knows where Iraq is". I got a great insight
into the bourgeoisie/proletariat divide in that moment, and I drew an
instant parallel to the dark ages. This seems to me to be the
definition of serfdom (After enlightenment, but before access).<br />
<br />
I want my car mechanic to know whatever in the fuck he/she wants to
know, and to be able to critically think as to properly question their
government, make wise decisions on health care, child raising, etc.
They're trying to put out our sacred flame of the enlightenment. Every
bit of money taken out of education, every extra pupil in a classroom,
every closed Adult Basic Education program -- they're all one more
depressant on that flame.<br />
<br />
Also, too: fuck Locke.<br />
<br />
~Nic<br />
<br />
**Edit I said fuck Kant: I was thinking Locke but wrote Kant. I've got no beef with Kant's <i>a priori </i>(although I used to hate the concept)<i>, </i>my beef is with Locke's private property nonsense.<i> </i>Better Orange Than Deadhttp://www.blogger.com/profile/06115750575805432531noreply@blogger.com0tag:blogger.com,1999:blog-4548817446353068204.post-7623635814162302342011-10-24T14:06:00.003-05:002011-10-24T14:07:20.171-05:00Fuck city livingA drive by shooting with over 30 rounds fired from 3 different firearms
at 1am (All fired within about 5 seconds) NEXT DOOR? A desk pig that
basically mocked me for calling the next day with worry about that, two
cars broken into down the block, and the dude who was trying to rob my
renters house? Subwoofers? Why do I live in the city?<br />
<br />
Whatever weapons were used in this fucking drive-by, they were serious shit.. The walls of that home are plaster, and apparently there were rounds that made it clear through the WHOLE FUCKING HOUSE. The fridge, which has the outside wall, and an inside wall between it and the direction of fire, has bullets lodged into the side of it. Apparently a few strays hit the neighboring house (on the other side). This fuckhole pig is annoyed with my concern?<br />
<br />
I can't properly show the vibe I got from him, but here's a little excerpt:<br />
Cop: "We don't have any information about any of those situations"<br />
Me: "uhhhhhhh ok? Are you a cop?"<br />
Cop: "uhhhhh yeah I am a cop"<br />
Me: "How am I supposed to feel about this? There was a fucking war
going on outside of my home last night. You can't give me any
information about any of it. What am I supposed to do? Tell me. Give
me some advice here."<br />
Cop: "Lock your doors and windows"<br />
Me: "Helpful. am I going to have to keep a loaded firearm under my pillow?"<br />
Cop: "It wouldn't be a bad idea. Get training and a handgun."<br />
Me: "Reassuring."<br />
<br />
6 Months ago all I had to worry about was obnoxious subwoofers. Now I
find myself plowing my gf off the bed to the floor at 1am because HOLY
FUCK WE'RE UNDER ATTACK!<br />
<br />
At least he'll see what he can do to up the patrol time for my area.<br />
<br />
~NicBetter Orange Than Deadhttp://www.blogger.com/profile/06115750575805432531noreply@blogger.com1tag:blogger.com,1999:blog-4548817446353068204.post-5106677161517556042011-10-14T23:59:00.000-05:002011-10-14T23:59:09.336-05:00STNG weighs in on gender issuesWatching Star Trek the Next Generation on 'flix is probably my best time waster ever. Anyhow, in "The Outcast" was this monolog from a person who was part of a "sexless" race, and she had feelings of being a woman her entire life, which is apparently forbidden on whatever-the-fuck planet she's from (Cut/Pasted from IMDB):<br />
<br />
<blockquote>
I am female. I was born that way. I have had those feelings, those
longings, all of my life. It is not unnatural. I am not sick because I
feel this way. I do not need to be helped. I do not need to be cured.
What I need, and what all of those who are like me need, is your
understanding. And your compassion. We have not injured you in any way.
And yet we are scorned and attacked. And all because we are different.
What we do is no different from what you do. We talk, and laugh. We
complain about work. And we wonder about growing old. We talk about our
families, and we worry about the future. And we cry with each other when
things seem hopeless. All of the loving things that you do with each
other, that is what we do. And for that, we are called misfits, and
deviants, and criminals. What right do you have to punish us? What right
do you have to change us? What makes you think you can dictate how
people love each other?<br />
<br />
<br />
The Judges Response:
I congratulate you, Soren. Your decision to admit your perversion makes it much more likely that we can help you.</blockquote>
<br />
<blockquote>
..Riker: "Did it occur to you that she might want to be like this?" </blockquote>
It's a beautiful episode, one among many.<br />
<br />
~NicBetter Orange Than Deadhttp://www.blogger.com/profile/06115750575805432531noreply@blogger.com0tag:blogger.com,1999:blog-4548817446353068204.post-58244638011571462862011-10-12T23:24:00.001-05:002011-10-12T23:38:59.731-05:00Fuck you, homosexual!The title is in reference to gingergate, and is intended to convey irony. <br />
<br />
(<a href="http://www.cnn.com/2011/10/12/us/minneapolis-bullying-schools/index.html?hpt=hp_c2">via</a>) "One school district bars teachers from taking a position on homosexuality."<br />
<br />
I don't understand this concept of "neutrality" with regard to
homosexuality... How do you remain neutral on a fact? Let me
hyperbolize:<br />
<br />
Student: "Hi, I'm Billy, I am gay."<br />
Teacher: "I can not confirm or deny the existence of homosexuality."<br />
Student: "How about if I just say I'm straight?"<br />
Teacher: "I CAN confirm the existence of heterosexuality."<br />
Student: "Doesn't the acknowledgement of one infer the existence of the other, <i>exempli gratia</i>: darkness implies light?"<br />
Teacher: "Why do people think I earn too much?"<br />
<br />
Am I misinterpreting their idea of neutrality? Perhaps I am taking them literally what they are asking for. To remain neutral on a characteristic is to not have an opinion on its existence (See: <a href="http://dictionary.reference.com/browse/agnostic">agnostic</a>(loosely)). Though what's implied (and what they really mean) is that teachers ought to remain neutral on the "good" or "bad/evil" of such a characteristic, however this is not possible.. Just as some people might think <a href="http://miauk.com/">Gingers are evil and should all be killed</a>(I went there), which is highly irrational since hair color (along with skin color, sex, etc, etc) are characteristics over which the holder has no control, homosexuality fits the same bill, and is therefore transcendent of any arbitrary judgement of goodness. The only choice a teacher has is to take a position something like:<br />
<br />
"The fact in the matter is that this particular (or that particular) child is homosexual(or hetrosexual). My purpose is to protect my students from hatred in any form, and therefore hatred, and/or bullying directed at any child is unacceptable. I will not remain neutral when a child is harassed, and it follows that I will not remain neutral when a homosexual child is harassed, the harasser will be punished."<br />
<br />
I remain neutral [and] on the moon. <br />
<br />
These fucking haters are so GOD DAMN stupid, and nicotine withdrawal makes me that much more fucking angry about it. Stop being a fucking hater. <br />
<br />
~Nic<br />
<br />
**edit: The MIA video was supposed to be interpreted far differently than it ended up being, and is used to progress a very long and old "ginger-phobia" tradition in UK, and other parts of Europe. This (not the video, the UK/euro issue) was an ace card I had in my back pocket during Gingergate, and didn't need to use.Better Orange Than Deadhttp://www.blogger.com/profile/06115750575805432531noreply@blogger.com0tag:blogger.com,1999:blog-4548817446353068204.post-70316830266042692512011-10-05T13:31:00.000-05:002011-10-05T13:31:15.782-05:00Rails 3 - unit testing validators with check validate reflection methodI don't know if this is to best practices or not (and I really don't give a shit -- this works great). Here's the idea:<br />
<br />
model: <br />
<pre><code>
class Submission < ActiveRecord::Base
validates_presence_of :title
validates_presence_of :first_name
<snip>
end
</code>
</pre><br />
I load some data in with a fixture to make the model valid.... blah blah<br />
<br />
unit test:<br />
<pre><code>
require 'test_helper'
class SubmissionTest < ActiveSupport::TestCase
def setup
@one = submissions(:one)
end
test "empty title invalidates" do
assert !check_validate(@one,"title")
end
test "empty first name invalidates" do
assert !check_validate(@one,"first_name")
end
.....
</code>
</pre><br />
Now the check_validate method, and the quick check method:<br />
<br />
<pre><code>
def check_validate(object,field)
#Make sure object is valid
assert_object_valid(object)
#set old to objects value
old = object.send(field.to_sym)
#send setter to object along with nil to blank it
object.send("#{field}=".to_sym, nil)
#set return value to boolean of valid? on object
return_value = object.valid?
#send setter to object for field with old value
object.send("#{field}=".to_sym, old)
#Make sure we leave the object valid when we're done
assert_object_valid(object)
#return the value
return return_value
end
def assert_object_valid(object)
assert object.valid?, "test entered with invalid object"
end
</code>
</pre><br />
<br />
It works great.. nice and DRY, this way I don't have to blank them all out, and put them all back.. ruby's reflection is a billion light years beyond any I've used for anything else ever. (Java? what?) I plan on modifying the check_validate to simplify other checks as well, and create my own library of test for common tasks. Maybe it already exists? I looked, and didn't find one.<br />
<br />
~NicBetter Orange Than Deadhttp://www.blogger.com/profile/06115750575805432531noreply@blogger.com0tag:blogger.com,1999:blog-4548817446353068204.post-41033683770247028622011-10-02T18:26:00.001-05:002011-10-03T08:15:33.803-05:00Liberal propaganda.**Edit: I spelled propaganda wrong. Again.<br />
<br />
Wheeee I've been saving that one. So I spend the last 2 days, about 16 hours working on my sweet new shed with my father. I've gotten him into reading some blogs, and we discussed at length a few repeating patterns we've both noticed (and are by no means immune to):<br />
<br />
1. There is a liberal dogma.<br />
2. I agree with a lot of it.<br />
3. We both have a hard time with any dogma.<br />
<br />
1: We all know what the liberal dogmatic stances are on everything from global warming, to birth control, to affirmative action, to every other goddamn thing under the sun. While I find myself in agreement with most all of the dogmatic stances I, become thoroughly annoyed when someone chimes in with a completely rational argument against one of them, and the chimer-inner is dismissed as a troll of some sort, and the argument is not explored. I haven't yet found myself labeled a troll on a blog (I don't comment much anywhere), but I can positively conclude that I would be labelled a troll should I chime in. <br />
<br />
Even when I am in complete agreement with a stance, political position/posture, or the like my brain immediately begins the devil's advocate program (v 30.3 It needs work, but it's done well for me). I don't do this to necessarily be argumentative, but to be exploratory. I believe this is a byproduct of the general troubleshooting skills I have honed over the whole of my life. I must consider as many alternatives as I possibly can, and should I find a logical conflict, I must do everything I possibly can to correct it. Logical inconsistencies infuriate me, although I have to live with a few (for example, the only logical conclusion I can draw from some of my new-found non-religious frameworks is that eating meat is unacceptable (pain/suffering/killing/etc of sentient beings), however, I continue to eat meat.. and probably will until I can no longer withstand the mental pressure to do otherwise). <br />
<br />
2: Yup. Most.<br />
<br />
3: Following dogma means acceptance without regard for the truth (should the actual truth be part of the dogma is beside the point). I have, since I can remember, absolutely refused to believe anything that I couldn't conclude with my own thought (when I eventually find the time to think about it. The queue is long). This is why I have no problem dismissing arbitrary authority -- which has caused me a lot of easily avoidable problems -- and making that dismissal quite outward.<br />
<br />
I have concluded that the label of troll, in some circumstances (I can't give a %) is intellectual laziness. It's simply name calling with the end of dismissal of an uncomfortable question (in the cases where it's lazy).<br />
<br />
While the comfort of dogma may have great appeal to some (and dogma is politically agnostic), I will not accept what I am told. Regardless of the authority of the preacher. <br />
<br />
To be cliche:<br />
<br />
<iframe width="420" height="315" src="http://www.youtube.com/embed/8jKrtlmd-bE" frameborder="0" allowfullscreen></iframe><br />
<br />
<br />
<br />
~NicBetter Orange Than Deadhttp://www.blogger.com/profile/06115750575805432531noreply@blogger.com1tag:blogger.com,1999:blog-4548817446353068204.post-47435313113628729382011-09-27T20:15:00.000-05:002011-09-27T20:15:44.558-05:00I'm about to slap someone..For the last goddamn week some fucking asshat has been parking across the street and down 2 or so houses. They pull up and about 10 people pour out of this vehicle and they proceed to test the nerves of the surrounding 2-3 blocks with wall-shaking bass. This, of course, annoys me endlessly. The passing vehicles with obnoxiously loud bass I've managed to deal with fairly well mentally.. as long as I know it will go away I can take a few deep breaths and forget it (When I first moved to Minneapolis in 1998 I thought I was going to die of panic attacks). But this lingering shit destroys my spirit.<br />
<br />
SO -- Calling the cops is useless, they're too busy pulling people over for trivial nonsense (esp. if they're a minority).. <br />
<br />
So what's a ginger to do?<br />
<br />
I think I am going to buy a few <a href="http://www.opentip.com/Sporting-Goods/Seasense-Air-Horn-Small-p-665499.html">Air Horn</a>s. I am going to rig something up so I can set it and leave with the goddamn thing blaring away. Leave it on the doorstep with a nice note that says "TURN YOUR FUCKING MUSIC DOWN YOU ASSHAT".<br />
<br />
What will I really do? Nothing. I'll sit and stew in my basement while my nerves drive me to fantasize about some form of payback for my torture. ..Oh, and continue to browse for homes in first-third ring suburbs.. and wish I made more money.<br />
<br />
~NicBetter Orange Than Deadhttp://www.blogger.com/profile/06115750575805432531noreply@blogger.com0tag:blogger.com,1999:blog-4548817446353068204.post-79689750763940133252011-09-26T14:02:00.002-05:002011-09-26T14:02:33.503-05:00We have a problemWe have a fucking problem here:<br />
<br />
<blockquote>A small town in Alabama is offering non-violent offenders the choice between doing prison time and paying a fine, or working their sentence off by going to church every week.</blockquote><br />
<a href="http://tpmmuckraker.talkingpointsmemo.com/2011/09/alabama_town_offers_church_or_jail_sentencing_choi.php?ref=fpb">From TPM</a><br />
<br />
~NicBetter Orange Than Deadhttp://www.blogger.com/profile/06115750575805432531noreply@blogger.com0tag:blogger.com,1999:blog-4548817446353068204.post-52830485036411343932011-09-26T11:54:00.000-05:002011-09-26T11:54:51.851-05:00Rails 3 - Check if any possibilities exist before validationIn this work project I have a few models: contest model, submission model, and subject model. Subject is a table that belongs to contest, AND subject. Some contests don't have subjects, but if they do, I need to have the user select one. These few snips of code worked well for that situation:<br />
<pre><code>
class Submission < ActiveRecord::Base
#Set up how the model works
belongs_to :contest
belongs_to :subject
#Validate the field we're talking about in this post:
validates_presence_of :subject_id,
:on => :create,
:if => :needs_subject?
</code>
</pre><br />
.. And later I defined needs_subject? as follows:<br />
<br />
<pre><code>
def needs_subject?
if self.contest.subjects.any?
return true
else
return false
end
end
end #End the model.
</code>
</pre><br />
So this allowed me to only check if there's a subject if there SHOULD BE a subject.<br />
<br />
Hope this helps someone.<br />
<br />
~NicBetter Orange Than Deadhttp://www.blogger.com/profile/06115750575805432531noreply@blogger.com0tag:blogger.com,1999:blog-4548817446353068204.post-50136951095703604522011-08-29T12:49:00.000-05:002011-08-29T12:49:12.584-05:00Probability of god making an earthquake and hurricane?0.<br />
<br />
Tell yourself whatever you want. For the record, the probability of a hurricane arising within 1 day, 1 week or 1 year after any arbitrary point (in this case, after an earthquake) is exactly the same, given seasonal adjustments. When events are close together, we notice. Had these two events been a year apart it would be a different story for the christnuts.<br />
<br />
Back to homework.<br />
<br />
~NicBetter Orange Than Deadhttp://www.blogger.com/profile/06115750575805432531noreply@blogger.com0tag:blogger.com,1999:blog-4548817446353068204.post-47287192251683950792011-08-25T13:21:00.001-05:002011-08-25T13:21:29.096-05:00LifeNet Autonomous netApparently my idea does exist, though it is in a quite broken-down and seemingly abandoned way. I would think that the source for that project could be branched and modified to do what I had proposed earlier. Find it here: <a href="http://thelifenetwork.org/">LifeNet</a><br />
<br />
~NicBetter Orange Than Deadhttp://www.blogger.com/profile/06115750575805432531noreply@blogger.com0tag:blogger.com,1999:blog-4548817446353068204.post-87110936660385760392011-08-23T20:48:00.001-05:002011-08-23T20:48:57.197-05:00I just had a 9/11 flashback..<div class="separator" style="clear: both; text-align: center;"><a href="http://www.cnn.com/2011/US/08/23/virginia.quake/index.html?hpt=hp_t1" imageanchor="1" style="margin-left:1em; margin-right:1em"><img border="0" height="250" width="250" src="http://i2.cdn.turner.com/cnn/2011/US/08/23/virginia.quake/t1main.washington.monument.gi.jpg" /></a></div><br />
It was really about the earthquake. I just saw it out of the corner of my eye, and had an "oh fuck, not again" moment for about 1/2 a second. Terrible shot.<br />
<br />
~NicBetter Orange Than Deadhttp://www.blogger.com/profile/06115750575805432531noreply@blogger.com0tag:blogger.com,1999:blog-4548817446353068204.post-42395400842130369942011-08-21T21:17:00.001-05:002011-08-21T21:51:34.389-05:00Ad-hoc autonomous wireless network for mobile devicesDictatorships, and oddly BART have practiced shutting down of cellular networks to quell protests and dissent. It is clear that something needs to be done to remove this powerful anti free speech weapon. I've thought about this all last week, but have no time to write the software, but I will outline it in hopes that someone will do it (or let me know if someone already has)<br />
<br />
The network should use both Wifi, and Bluetooth technologies.<br />
It will work in a fashion similar to how Samba systems "elect" the controller (within the software).<br />
Simple "multicast" type messages will be used to find neighbors, and use a common messaging protocol that requires nothing other than a private IP address (<br />
Network splits should be dealt with by having another intermediary relay messages between newly autonomous segments.<br />
IP addresses should be randomly assigned in such a way that there will not be collisions between segments.. Address should use a class-A private address (10. etc).<br />
All traffic destined to the internet should be encrypted by the sender with a destination to be safe-server somewhere in the world with stable government and free speech laws. <br />
The server host will remain neutral, and ensure the secrecy of all encryption keys, with a complete revocation infrastructure incase of compromise.<br />
Should one of the participating mobile devices suddenly get internet access, it should be immediately shared, and use adaptive throttling. <br />
If multiple devices have access, a delegation system should be used to distribute the load.<br />
Internet sharing should be mandatory, but with a pre-set limit of usage (eg. "I'll share up to 50MB of my connection when I get access")<br />
Any queued messages (that would be distributed on the network for later delivery) will be delivered by at least two devices, if not all to ensure integrity.<br />
<br />
A network working like this will de-fang any cut off of internet/cellular access, as participants will still be able to communicate among themselves. The technology we currently have is capable of doing this with no physical modifications, and a moderately sized application. The application will probably require root/su access to the device, as the device will have to switch to access point mode. Devices that are not capable of ad-hoc will be used as Wifi to BT proxies.<br />
<br />
Make it fucking happen, now.<br />
<br />
~Nic<br />
<br />
** Added:<br />
<br />
... for information to start moving out to the internet should take nothing more than ONE node gaining internet access. Since all messages (outgoing, and a log of internal messages) will be distributed to ALL nodes, all messages should eventually see the light of day. In the case that the primary relay-to-internet server is taken down, there should be fall-back machines. Since the messages leaving the network will be encrypted there will need to be some kind of central repository.<br />
<br />
It is important to note that local messages in the network (not with the final destination of the internet) will not be encrypted in the local network, only encrypted on their way out. This will disallow tampering. The key for encryption for distributed outbound messages will be encrypted with the senders key. It will also be important to have everyone informed that all messages will eventually see the light of day. Though they (the messages) should be anonymous, the eventuality of them being out in the open will allow, theoretically, for some self policing -- If a group is cut off from internet access, uses this software and is found out to have been coordinating some kind of violence, everyone will know.<br />
<br />
I would suspect that the safe-server would use some kind of application that posts the messages to twitter and other similar places, but also replicates them to other machines (post-encryption) to ensure their "liberation". <br />
<br />
Not only does this have the potential to deal with internet cut-offs, but also to deal with emergency situations where cell service is overwhelmed, or destroyed. The idea arose from my interest in the historic, and recent use of ham radio in catastrophic situations.Better Orange Than Deadhttp://www.blogger.com/profile/06115750575805432531noreply@blogger.com0tag:blogger.com,1999:blog-4548817446353068204.post-5628475183124222532011-08-17T21:21:00.000-05:002011-08-17T21:21:45.662-05:00Stephen Hawking's The Grand DesignThe book The Grand Design by Stephen Hawking just became available to me via the Hennepin County Public Library (in ebook format). I suspect this will be a provocative book: <br />
<blockquote>...Philosophy is dead. Philosophy has not kept up with modern developments in science, particularly physics. Scientists have become the bearers of the torch of discovery in our quest for knowledge (Hawking 14).</blockquote><br />
~NicBetter Orange Than Deadhttp://www.blogger.com/profile/06115750575805432531noreply@blogger.com0tag:blogger.com,1999:blog-4548817446353068204.post-48144709235389336552011-08-17T21:04:00.000-05:002011-08-17T21:04:35.714-05:00Security through obscuritySecurity through obscurity is nothing but a false sense of security. Ma bell learned this with the advent of Phreaking, and a 2600Hz cracker jack box whistle. Countless others have learned this the hard way as well. I have a long time customer who insists on using the 4D platform, which stores confidential customer information in a not-so-awesome way. I've been pressuring him for a long time to move on to something better, but he is in a endless loop of the sunken cost blues. He says "I've got all this money in it already" which he says to only convince himself that he must put more money into it. You know the drill. Anyhow, I'll use this as an opportunity to plug my latest favorite large scale web application: <a href="http://www.magentocommerce.com/">Magento</a>. Yes, it's written in PHP. I'll forgive that (Drupal is written in PHP as well, and is fairly sound). <br />
<br />
I am spending some somewhat serious time learning this platform so I can move my current and future clients away from their archaic ASP/4D/ColdFusion garbage (not to mention the other proprietary garbage that good salespeople shove down unknowing CEOs throats.) Know anyone who needs a new webstore? If they have 6 months to wait, I will set one up at a deep discount for a chance to set up my first production ready Magento.<br />
<br />
~NicBetter Orange Than Deadhttp://www.blogger.com/profile/06115750575805432531noreply@blogger.com0tag:blogger.com,1999:blog-4548817446353068204.post-40086017685542302692011-08-17T20:24:00.000-05:002011-08-17T20:24:44.635-05:00Well, that was funMy new topic is something that I've been tossing around in my mind for about a year and a half, and I am working up a strategy for attacking it coherently. My thesis is along the lines of: "The rapid progression of technology, specifically since 1995, mirrors the drawn-out progression of human civilization". Stay tuned. <br />
<br />
I have to mention the past few posts, emails and a few Google+ messages I've been dealing with:<br />
Though I'm a strong proponent for metaphorical equine abuse, I will end my last string of posts with a bit of nuanced sarcasm mixed with some serious observation. I've learned some things in the past two or so weeks: a) I am really not afforded much space for an opinion on race matters without expending great energy on fending off straw men attacks, even from some very unexpected corners (I can only interpolate a reason from the messages I have received: this is because I am i)white ii) male. I am sure this will be parsed, twisted, and beaten nearly to death, but this is purely observation, and I've confirmed it's objectivity.) b) Discussion on race is an onion with an incredible number of layers that must be traversed before even thinking of any kind of open inquiry. c) I am now interested in taking at least 2 more upper division ethnic studies classes. <br />
<br />
Oh, and for good measure: fo guck yourself. ;)<br />
<br />
~NicBetter Orange Than Deadhttp://www.blogger.com/profile/06115750575805432531noreply@blogger.com0