stopping an infinite stream in elixir
Suppose you have an infinite stream. You can stop it as shown here
listing all rails routes
Found myself needing a list of routes in an rspec controller test. This did the trick:
no sound in ubuntu 15.04 skype
Had no sound after a fresh install, and everything in skype was showing virtual device. This is what fixed it:
anonymous controllers with rspec
If you have new routes in your anonymous controller, the docs say you should do this:
However, in my case, the following change helped:
My First Video Post on Jekyll
Steve Austin: Astronaut. A man barely alive. Gentlemen… we can rebuild him. We have the technology. We have the capability to make the world’s first bionic man. Steve Austin will be that man. Better than he was before. Better. Stronger. Faster.
My name is Rhoda Morgenstern. I was born in the Bronx, New York in December of 1941. I’ve always felt responsible for World War II. The first thing I remember liking that liked me back was food. I had a bad puberty; it lasted seventeen years. I’m a high school graduate. I went to art school. My entrance exam was on a book of matches. I decided to move out of the house when I was twenty-four. My mother still refers to this as the time I ran away from home. Eventually, I ran to Minneapolis, where it’s cold and I figured I’d keep better. Now I’m back in Manhattan. New York, this is your last chance!
Dr. David Banner: physician; scientist. Searching for a way to tap into the hidden strengths that all humans have… then an accidental overdose of gamma radiation alters his body chemistry. And now when David Banner grows angry or outraged, a startling metamorphosis occurs. The creature is driven by rage and pursued by an investigative reporter. The creature is wanted for a murder he didn’t commit. David Banner is believed to be dead, and he must let the world think that he is dead, until he can find a way to control the raging spirit that dwells within him.
My First Post on Jekyll
Steve Austin: Astronaut. A man barely alive. Gentlemen… we can rebuild him. We have the technology. We have the capability to make the world’s first bionic man. Steve Austin will be that man. Better than he was before. Better. Stronger. Faster.
My name is Rhoda Morgenstern. I was born in the Bronx, New York in December of 1941. I’ve always felt responsible for World War II. The first thing I remember liking that liked me back was food. I had a bad puberty; it lasted seventeen years. I’m a high school graduate. I went to art school. My entrance exam was on a book of matches. I decided to move out of the house when I was twenty-four. My mother still refers to this as the time I ran away from home. Eventually, I ran to Minneapolis, where it’s cold and I figured I’d keep better. Now I’m back in Manhattan. New York, this is your last chance!
Dr. David Banner: physician; scientist. Searching for a way to tap into the hidden strengths that all humans have… then an accidental overdose of gamma radiation alters his body chemistry. And now when David Banner grows angry or outraged, a startling metamorphosis occurs. The creature is driven by rage and pursued by an investigative reporter. The creature is wanted for a murder he didn’t commit. David Banner is believed to be dead, and he must let the world think that he is dead, until he can find a way to control the raging spirit that dwells within him.
intro to celluloid
I started to use Celluloid to speed up some tasks, and I like the simplicity it offers.
For my specific case, I wanted to speed up some downloads/uploads. Here’s how you do it:
So, if we do this:
will not use Celluloid the Ruby main thread becomes an Actor.
When you write YourClass.new.do_something you are actually doing a blocking call and invoking do_something
on the YourClass instance (which is contained within an actor). Thanks for the correction Sam Williams
This returns a future, which may or may not be completed at the time you need it. Each future exposes a method called ready? which you can call to see if the future finished.
So, you could do something like this:
Now, imagine that you want to run your processing using multiple threads at the same time. You could create a number of futures inside a loop, and then check them all with ready? and append to them once some of them have finished. I did that in the beginning as well :) Or, you could just use the pool method that Celluloid offers. So, to parallelize the class above, we can do this:
And the code above will queue 4 jobs to your pool. Notice that we’re sleeping for some seconds, to allow the jobs to finish. Yeah, I’m not a big fan of this approach either, because your jobs may take much longer, or much less than 60 seconds.
Luckily, there’s another class from Celluloid that comes to our rescue. Enter Celluloid::Condition:
I know this was quite a whirlwind introduction to Celluloid. I invite you to experiment with it for a bit. I really like the power it offers you, and I’m quite sure you will find it useful too. As I learn more about it, I’ll try to post more updates/tips/tricks.