Paperclip dynamic styles based on polymorphic parent class doesn't work (Rails 4.2.5, Paperclip 4.3.1)

Basically I have an Image model which polymorphically belongs to imageable which are by far List and Item. Since an image will have its own attribute and relationship, I don’t want to treat images like attributes of the List and Item and mess it up. So I create the Image model. What I want to […]

Read in external links in PHP

I know how to do this in Ruby, but I want to do this in PHP. Grab a page and be able to parse stuff out of it.

Assets in espresso breaks my app

Here is my simple app: class Blog < E map ‘/’ # actions goes here end app = do # assets_url ‘/’, true mount Blog end server: :Thin, Port: 6040 It works well until i uncomment assets_url ‘/’, true. If i do so, all my routes returning 404 and only routes pointing to […]

How to remove dupes from blocks of text

What’s a smart and easy way to remove dupes within blocks within a file of text. Each block is separated by two newlines. BEFORE: apple banana apple cherry cherry delta epsilon delta epsilon apple pie delta delta AFTER: apple banana cherry delta epsilon apple pie delta Thanks. Should work on a Mac. Allow unicode. Any […]

Cannot load Google maps

One of the options in my app is launching the google maps. The scenarios: Regular install => adb install xx.apk -> maps are loading successfully. Install it with test server -> calabash-android gen xx.apk, etc. -> the maps are not loading. In the Android monitor I got the next message in the logcat: 05-14 18:43:18.239: […]

Linked List written in ruby

I’m preparing for a technical interview and will be asked to write the algorithm for a linked list in ruby. I understand linked lists completely, but have struggled writing the code. Can someone show me how this is done? I started it below.. class Node def initialize(item) @item = item @next = nil end end

Why is my guard-rspec test failing?

I set up my guard-rspec environment using the techniques described in this tutorial. I’m also practicing namespacing as described in Programing Ruby starting on page 240. My current project directory is on github in the stack-overflow-post branch. I’m using: ❯ ruby -v ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-darwin15.0] ❯ rbenv -v rbenv 1.0.0 ❯ rbenv […]

Writing Automated scripts to configure device

My requirement is like this: I need to log in to a remote device (say Router/switch) and execute following commands. telnet xx.xx.xx.xx //give password here sys interface g x/x/x shut desc free-port exit There are Hundreds of devices for which I cannot waste time doing above damn thing 100 times. I need to write a […]

Sending method to child in Ruby class? Inheritance confusion

I have the following code: class Bike attr_reader :chain def initialize @chain = default_chain end def default_chain raise ‘SomeError’ end end class MountainBike < Bike def initialize super end def default_chain 4 end end mb = p mb.chain When in the initialization we call super, I would expect the default_chain of the super class […]

Check if string contains only floats separated with commas in Ruby

How can I check if string contains only floats separated by commas with no space. Something like below: str = “0.0687987167581341,0.120311605902415,89.8399554017928,198.151088713489” #true str = “0.068798716758f1341,0.120311605902415, 89.8399554017928,198.151088713489” #False because of “f” in the first value. str = “0.0687987167581341 0.120311605902415” # False because of no space and comma. Basically, how can I check if a string is […]

Ruby is the best programming language in the world - Ruby on Rails.