« first day (424 days earlier)      last day (2831 days later) » 

11:28 AM
o/
 
 
2 hours later…
1:47 PM
good morning all
 
Good morning.
 
lol
@WayneConrad have you ever written spaghetti code because you were in a rush?
i am so guilty of this right now i hate myself
 
My biggest sin, when in a hurry, is making a class do too much.
I often get to a place in my design where there's a sort of "god" class that has the main application logic in it. The "main loop," as it's sometimes called. And I am often not so good at figuring out how to break that up.
 
2:03 PM
sometimes i get requirements in the morning and the boss is like get it done by the end of the day so i just go: screw it.
 
One thing that makes me feel uncomfortable is when a class has a great many instance variables. I always feel like I'm doing something wrong in that case.
    def initialize(argv)
      @logger = OlioLogger::NullLogger.new
      handle_errors do
        @args = Arguments.new(argv)
        @config = Config.load(@args.config_path)
        @config.accept_overrides(@args)
        @logger = LoggerFactory.make(@config.log)
        @imap_client = ImapClient.make(@args.dry_run, @config.imap)
        @email_client = EmailClient.new(@config.imap, @imap_client)
        @rabbit = Rabbit.make(@args.dry_run, @config.rabbitmq)
        @old_email_detector = OldEmailDetector.new(@config.archival_days)
That's a lot of state.
 
tell me about it, Rubymine goes nuts if i have that in my class, i get "yellow" warning all over my class
you can just imagine what my OrderStruct was like..
lol
 
Yeah. And that's not code I stopped improving for lack of time. I stopped improving it for lack of skill.
 
you? lol lack of skill? i dont think so sir
 
^ that code
 
2:08 PM
oh looks like my code in my OrderStruct
i ended up moving those into their own methods:
like

def logger
  @logger ||= LoggerFactory.make(@config.log)
end

def imap_client
  @imap_client ||= ImapClient.make(@args.dry_run, @config.imap)
end

def email_client
  @email_client ||= EmailClient.new(@config.imap, @imap_client)
end

def rabbit
  @rabbit |= Rabbit.make(@args.dry_run, @config.rabbitmq)
end

def old_email_detector
  @old_email_detector ||= OldEmailDetector.new(@config.archival_days)
end
and then look at the method names like imap_client, email_client ..
looks like a Client class or something is trying to get out of there
 
Hmm. You're onto something there. ImapClient is low level; EmailClient contains application logic. They always get made together, and the main loop never uses ImapClient. I can move their making into a factory.
 
but my ideas might not make sense at all so yea lol
 
OK, I'm going to take some time and see if this monster can't be made better.
 
Oh, I have that book. Fat lot of good it did me, haha!
OK, first improvement due to what you noticed.
    @imap_client = ImapClient.make(@args.dry_run, @config.imap)
    @email_client = EmailClient.new(@config.imap, @imap_client)
^ this, became this v
    @email_client = EmailClient.make(@args.dry_run, @config.imap)
That's one small step for a constructor, one giant leap for putting this class on a diet.
 
2:21 PM
looks like two different classes LoggerFactory, OlioLogger ..
looks like a duck is hidden there?
@WayneConrad
i dont know what you are doing with the Config.load(@args.config_path), this likes something that needs to be somewhere else , like where the application starts or something
Configs are usually "global" objects, unless you are tying to have "class" based configs in which case you could maybe use hooks or something to merge "class config {}" with "global config {}
 
Yeah. OlioLogger::NullLogger is shared by multiple projects. It's a general purpose "logger that doesn't log to anything."
 
i dont know what you are doing with the Config.load(@args.config_path), this likes something that needs to be somewhere else , like where the application starts or something
Configs are usually "global" objects, unless you are tying to have "class" based configs in which case you could maybe use hooks or something to merge "class config {}" with "global config {}
 
This is the Main class. It is where the application starts.
Now, how arg parsing and config parsing work, that part I'm proud of. That came out really nice.
That's a pattern I'll use again on other projects.
 
oh ok that makes sense
this is really fun
+D
 
Yes it is. And very helpful... thanks!
 
2:27 PM
oh whatever i know is what you taught me
lol
 
Probably the coolest line of code there is @config.accept_overrides(@args). I look at that line of code and know what it means without having to look inside either config or args.
 
yea it looks nice!
 
Isn't it just geeky as all heck when a line of code can make you grin?
 
oh wow..
lol yes you could probably just inline that
@config = Config.load(@args.config_path). accept_overrides(@args)
 
2:30 PM
@BasementKeyboardHero ran into my own 2yr old one a week ago :P github.com/rails/rails/issues/12114
 
Guys, do you have any experience with sidekiq and sidetiq?
 
@Nima I could, but I'd have to have accept_overrides return self. I don't like for a method to have both side-effects and a return value.
 
good point
 
2:57 PM
I'm not positive why I like that rule. It does make method naming easier: If it has a return value, it's a pure function, and it gets a noun name. If it has a side-effect, it gets a verb name.
But that's not really a convincing reason.
You could decide that a side-effect method could have a return value, but gets a verb name... no problem there.
I think I picked up the idea from reading about functional programming.
 
3:57 PM
Grumble grumble. Thunderbird won't allow me to save an account when the password is incorrect. Which means that every time the sysadmin tells me to try again, I have to repeat all of the account setup again.
 
lol
who still uses thunderbird
 
<--- last guy on Earth using it. But not for long.
Aha. I fooled it into saving the account. First you have to click on "manual setup", and then "advanced settings", and then "done." <roll eyes>
@Nima What do you use?
 
@WayneConrad Outlook.com
@WayneConrad i can get ALL my emails from there and also send them from there
i have my Gmail (personal, work), Yahoo, Work IMAP, etc managed from there
 
Oh, ain't gonna do that. Outlook whipped me with a wire coat hanger when I was a child. I know it's gone to rehab and got religion and all that, but I just can't.
 
not Outlook , Outlook.com
i actually hated the outlook mailclient
www.outlook.com
 
4:13 PM
I know. But it has the same name. Shudder.
 
lol outlook.com is pretty much like have the OSX Mail on the web, i really needed a central account to manage all my emails from.
i am on OSX.. and this is off topic but i feel like apple's software quality is being trashed
 
That's a shame. That's always been the reason to buy Apple. What's going wrong with it?
 
buggy finder, slow animations, useless features, .. meanwhile instead they keep making "thiner" computers..
they are pretty much becoming a fashion company
Jobs would have never sacrificed quality
 
And $10,000 watches, I guess.
 
exactly.. fashion company.. and i guess people have decided with their pockets that is the direction it should take
the general public simply does not care
they just want something that looks shiny so they can take it to starbucks and show off while drinking "lattee"
 
4:18 PM
Haha!
 
they don't work with their machines like we do
frankly im considering switching back to linux
</end of rant>
lol
 
I'm fascinated by the way that the people take this idea, this computer revolution, and make it succeed, but different than the visionaries ever thought. Not with recipe files on a kitchen terminal, or with everyone knowing how to program, but with fashion statements and social networking.
 
THANK YOU
finally someone said it
 
I don't think I share your disdain for the phenomenon. I'm more fascinated by it.
In a "Fascinating, captain" kind of way. With the raised eyebrow and all that.
 
lol
it gets under my skin
 
4:23 PM
Hehe, you don't say.
 
@BasementKeyboardHero , what are your thoughts on this
 
where do i start? wasn't following the conversation in the middle of a commit x.x
 
10 mins ago, by Nima
i am on OSX.. and this is off topic but i feel like apple's software quality is being trashed
 
@BasementKeyboardHero , discussing how the whole salvation through technology is going in an opposit direction that we imagined: not having AIs but rather Gold shiny macbooks and fancy watches..
 
4:25 PM
I got a mac last week and I absolutely love it
 
lol
 
oh we're talking about the IcrapWatch
 
yup
 
Apple are geniuses, consumers are morons
 
i was saying how apple is becoming a fashion company
 
4:26 PM
By far
All those gold crap and whatnot is just ridiculous consumerism
Yet a lot of idiots are gonna line up to get them due to the brand
 
people with their pockets have decided that they dont want to have quality software, they just want something that looks shiny so they can take it to starbucks and show off while drinking "lattee"
 
The profit margin on the bling has got to be huge. Maybe that leaves more money for software dev...
 
Can't deny the genius behind that, after all as a corporation their ultimate goal is maximizing profit
 
yes
 
My experience with osx (as short as it is) can be described with one word: Happiness
I v never had anything that runs as smoothly as that laptop
 
4:29 PM
the thing is the general public dont work with their machines like we do, they just use it for entertainment , meanwhile engineers are just left alone having to put up with useless features like "tagging" instead of having a better finder
 
It is overpriced, but there is nothing that offers anything remotely close to their quality and performance
Are you on yosemite ?
 
yes, i used the previous versions of OSX and i can honestly say Yosemite is the buggiest one
 
weird, so far so good
 
were you on windows before? just curious
 
but then again it's a brand new laptop
I was on mint and ubuntu
And before that I was on windows
 
4:30 PM
lol funny i was just saying im considering switching back to linux
 
This is the first time this week that I haven't had four things to do at once. It feels weird.
 
lol i have work to do but i just rather waste my time here
lol
 
Main bone I had to pick with linux is the lack of adobe software
 
oh yea
like photoshop?
 
Yeah. Adobe is not friendly to the OSS world.
 
4:31 PM
especially photoshop
I have designs to slice up
 
linux is really only for devs
lol
 
And photoshop "portable" is just no
What about devs that have to deal with front end :P
 
lol ignored
wait what are the photoshop alternatives
there was one that was pretty good
 
There's the gimp. It does a lot, but its user interface changes every 12 months. That's a problem for someone who doesn't use it frequently.
Every time I load the gimp, everything has moved again.
 
4:39 PM
good luck getting a designer to work on it instead of ps
 
i know nothing comes even close to PS
 
A designer is going to have years of muscle memory invested in PS. Having to switch to the gimp would be painful.
 
as much as i hate to say that..
 
And from what I've seen of PS, it's UI is just better. More polished, easier to use.
 
you can get ps to run on linux but it's a hit and miss thing
well one is os the other comes with a 1000$ price tag
The next version will be subscription based
@WayneConrad since you got free time why not get that banjo out ^^
 
4:43 PM
Haha! I have a coworker who prefers I don't play it at work.
He's on pain pills for a bad back, and when I play, he pops them at about twice the normal rate.
 
simple doubt here.
scope :archived, lambda { | | where("archived is NULL or archived = ?", true) }
archived attribute is being used twice, anything better ?
 
where("coalesce(archived, true)")
 
wooooh whats that
Super, works :)
 
Two things going on here. First is that you don't have to compare a boolean with true. where foo = true is the same as saying just where foo
 
4:57 PM
coalesce?
 
The second is the coalesce function. If the left argument is not null, the result is the left argument. If the left argument is null, the result is the right argument.
 
that was impressive wayne
 
that was wayne impressive
 
lol
 
really impressive, and way too fast , cheers :)
 
5:00 PM
I'm glad it helped
 
like lightening wayne strikes!
 
In case of false value, it's not the same result ?
 
I don't understand what "it" is in your question.
 
lambda { | | where("archived is NULL or archived = ?", false) }
 
Oh, my mistake.
Change true to false.
Sorry about that.
No, no, wait....
Hahaha. I'm trying to write my code and chat here at the same time, and doing both of them poorly.
where("not coalesce(archived, false)"
 
5:12 PM
hahaha :D ok, I must track this chat group I know you will always be here, I can learn new tthings for sure. :)
 
Now you guys can take back all that stuff about "like lightning" :)
@Nima You are welcome to hang out here.
 
:D:D im laughing out
 
@WayneConrad love being here
 
@Nima I think that was directed to me ;)
 
@Nithin Did that last one work?
 
5:19 PM
lol
 
Oh yea it did :) Thank you.. Ill run lot of questions on you from now on :P
 
That'd be great! Just do me a favor, and please ask the room rather than me specifically. I'll answer when I'm around and on those rare times I know the answer. And I'll sometimes even answer correctly.
 
Sure :)
 
yes you can also ask me, and chances are i will answer it wrong and then wayne will correct us both
lol
 
okies done )
 
5:36 PM
This is exciting. I get to use ConcatenatingEnumerator in production code. Woot!
 
alias rs="rails s"
love being lazy
lol
 
5:55 PM
:)
I wonder if there's a way to make IO.open("compressed_file.gz") decompress the file on the fly, letting me read it as though not compressed.
 
6:11 PM
what is the difference between IO.open and File.open?
 
IO.open will open things other than files on disk.
 
like you can read urls?
 
121
A: Open an IO stream from a local file or url

Aaron Hinniopen-uri is part of the standard Ruby library, and it will redefine the behavior of open so that you can open a url, as well as a local file. It returns a File object, so you should be able to call methods like read and readlines. require 'open-uri' file_contents = open('local-file.txt') { |f| ...

 
neat
 
This came out really neat. This class takes multiple log paths, and returns an enumeration that lazily reads the logs. Behind the scenes, it opens a file, yields each line, closes the file, opens the next file, yields each line, closes the file, and so on.
  class Logs

    def initialize(paths)
      @paths = paths
    end

    def lines
      logs = @paths.map { |path| Log.open(path) }
      ConcatenatingEnumerator.new(logs)
    end

  end
 
6:19 PM
oh wow, is this the result of refactoring since this morning?
 
No, different program.
 
what does ConcatenatingEnumerator do
 
It takes zero or more enumerations and glues them together so they act as a single enumeration.
So, for example:
 
that sounds really fancy
 
a = [1, 2]
b = [3, 4, 5]
enum = ConcatenatingEnumerator.new([a, b])
enum.each { |e| p e }
# 1
# 2
# 3
# 4
# 5
In this case, I want to treat multiple log files as though they were a single log, and enumerate over each line of that single imaginary log.
 
6:25 PM
ooh
so instead of doing (a + b).each { |e| e } or something..
 
Yes. Reading all the lines and joining them into one large array would be slow and consume enormous amounts of memory. These are rails log files...
 
very nice
 
Thanks.
Sometimes the code comes out nice.
There's only about 10 lines of code that make ConcatenatingEnumerator work, too.
 
it frustrates me how some people can write so little lines of code and accomplish so much with it
 
It takes a lot of time to write very little code.
I think I spent an hour writing ConcatenatingEnumerator. Maybe two.
 
6:33 PM
i wonder why our brains work that way
hey i have a stupid question
a gem has this in the lib folder:

module Auth
        extend ActiveSupport::Concern

        included do
          helper_method :try_current_user
           ..
        end
end
how can i monkey patch this to add another helper_method to it?
I tried this but with no luck

    Auth.module_eval do
       included do
          helper_method :is_admin?
        end
    ...
    end
 
6:48 PM
You're going to wrap the #included method.
Let me come up with an example.
Oh, wait, this isn't a normal module. We're in active support...
 
it keeps throwing an exception:
Cannot define multiple 'included' blocks for a Concern (ActiveSupport::Concern::MultipleIncludedBlocks)
 
The answer is going to be inside active support.
 
def included(base = nil, &block)
      if base.nil?
        raise MultipleIncludedBlocks if instance_variable_defined?(:@_included_block)

        @_included_block = block
      else
        super
      end
    end
 
I'd have to get deeper in this code than I have time for right now. It's got great comments and looks clean, though.
 
np
dont waste time on it
 
7:19 PM
This program came out nicer than that go-se I showed you earlier:
    def run
      logs = Logs.new(@args.paths)
      stats = Stats.new
      parser = Parser.new(stats)
      logs.lines.each do |line|
        parser.parse(line)
      end
      StatsPrinter.print(stats)
    end
 
nice!
 
Thanks.
 
8:05 PM
omg this is driving me nuts
i want to have a helper module that i can use in my Controllers as well as in my Config files in rails
module Helpers
  def foo
  end
end

config/navigation.rb
...
 foo

HelloController
def index
  foo
end
end
 
@Nima What's the problem?
 
8:25 PM
@Nima By which I mean, what part of it can't you figure out?
 
@WayneConrad thanks, i was trying to do something that didnt made sense
lol
see i have a method like this as a controller helper:
def is_admin?
end
which determines if the logged in user is admin
then i also have this code in my config/navigation.rb
def is_admin?
..
end
i wanted to move is_admin? into a module and include it so that both of them can access it but i couldnt figure it out
i dont think you can "include" a module in a config file in rais
rails *
 
if the config file is ruby code, you should be able to
 
this was my code:

module Helpers
    module Auth
      extend ActiveSupport::Concern

      included do
        helper_method :is_admin?
      end

      def is_admin?
        current_user.try(:has_role?, "admin")
      end
    end
  end
in my navigation.rb i had

include Helpers::Auth

and in my ApplicationsController i had that as well:
include Helpers::Auth
anyways i dont wanna bother you
 
You were getting an undefined constant, right?
 
undefined method `include' for #<#<Class:0x007f9005147188>:0x007f8fe887b250>
if i add the include Helpers::Auth in my config/navigation.rb it would give that error
ooh wait this is the gem's issue lol

look at this:

def self.eval_config(navigation_context = :default)
      context = SimpleNavigation.config_files[navigation_context]
      SimpleNavigation.context_for_eval.instance_eval(context)
    end
 
9:08 PM
I don't see what you see
 
woot looks so nice
 
thought you might enjoy that
lol
all these themes are going to make me convert to sublime eventually
but im not ready to lose the ability of looking straight through gem's source code by just clicking on the method name yet
 
got it it looks amazing
 
 
3 hours later…
11:59 PM
hello... How to use Rails with nginx as server in codio?
 

« first day (424 days earlier)      last day (2831 days later) »