Search Results

Search found 16 results on 1 pages for 'smotchkkiss'.

Page 1/1 | 1 

  • Help setting up command line gist

    - by smotchkkiss
    setup I'm following defunkt's gist setup guide. [smotchkkiss ~]$ sudo gem install gist [smotchkkiss ~]$ git config --global github.user "my github name" [smotchkkiss ~]$ git config --global github.token "my github token" [smotchkkiss ~]$ echo "puts 'hello, gist.'" > hello.rb [smotchkkiss ~]$ gist hello.rb output Usage: open [-e] [-t] [-f] [-W] [-n] [-g] [-h] [-b <bundle identifier>] [-a <application>] [filenames] Help: Open opens files from a shell. By default, opens each file using the default application for that file. If the file is in the form of a URL, the file will be opened as a URL. Options: -a Opens with the specified application. -b Opens with the specified application bundle identifier. -e Opens with TextEdit. -t Opens with default text editor. -f Reads input from standard input and opens with TextEdit. -W, --wait-apps Blocks until the used applications are closed (even if they were already running). -n, --new Open a new instance of the application even if one is already running. -g, --background Does not bring the application to the foreground. -h, --header Searches header file locations for headers matching the given filenames, and opens them. return value nil help! nil return value? What gives? No new gist appears in my My Gists page on github.

    Read the article

  • OpenSSL support for Ruby: "Cipher is not a module (TypeError)"

    - by smotchkkiss
    The Problem Our systems admin needed to upgrade the packages on our CentOS 5.4 dev server to match the packages on our production server. The upgrade affected ruby and/or openssl. We run a Ruby on Rails issue tracking system called Redmine that is deployed with Passenger on Apache. Everything worked before the server update, but when trying to access the ticket system now, I get the following error: Error message: Cipher is not a module Exception class: TypeError Application root: /home/dev/rails/redmine-0.8.7 I've been trying so hard to fix this problem but I can't seem to beat it. I have tried following this guide: http://iamclovin.posterous.com/how-to-solve-the-cipher-is-not-a-module-error When I try require 'openssl' in IRB, I do see a true return value. However, I'm still seeing the Cipher.rb is not a module TypeError when accessing the ticket system. Possibly (probably) related: I've tried updating Passenger, but when I try passenger-install-apache2-module I see: Checking for required software... * GNU C++ compiler... found at /usr/bin/g++ * Ruby development headers... found * OpenSSL support for Ruby... /usr/lib/ruby/1.8/openssl/cipher.rb:22: Cipher is not a module (TypeError) Any help?

    Read the article

  • How to scan local network (LAN) for connected devices (Mac OS)

    - by smotchkkiss
    I'm basically looking for something like this but available on Mac. I am trying to connect a new workstation to our wireless multifunction printer and I'm having a hell of a time getting the device to spit out an IP for me to connect to. Is there a way I can scan the network somehow? If it makes a difference, the new workstation is using Mac OS X 10.6 Thanks in advance :)

    Read the article

  • How to scan local network (LAN) for connected devices (MacOS)

    - by smotchkkiss
    I'm basically looking for something like this but available on Mac. I am trying to connect a new workstation to our wireless multifunction printer and I'm having a hell of a time getting the device to spit out an IP for me to connect to. Is there a way I can scan the network somehow? If it makes a difference, the new workstation is using MacOS X 10.6 Thanks in advance :)

    Read the article

  • Why can I access private/protected methods using Object#send in Ruby?

    - by smotchkkiss
    The class class A private def foo puts :foo end public def bar puts :bar end private def zim puts :zim end protected def dib puts :dib end end instance of A a = A.new test a.foo rescue puts :fail a.bar rescue puts :fail a.zim rescue puts :fail a.dib rescue puts :fail a.gaz rescue puts :fail test output fail bar fail fail fail .send test [:foo, :bar, :zim, :dib, :gaz].each { |m| a.send(m) rescue puts :fail } .send output foo bar zim dib fail The question The section labeled "Test Output" is the expected result. So why can I access private/protected method by simply Object#send? Perhaps more important: What is the difference between public/private/protected in Ruby? When to use each? Can someone provide real world examples for private and protected usage?

    Read the article

  • Rails: Create method available in all views and all models

    - by smotchkkiss
    I'd like to define a method that is available in both my views and my models Say I have a view helper: def foo(s) "hello #{s}" end A view might use the helper like this: <div class="data"><%= foo(@user.name) %></div> However, this <div> will be updated with a repeating ajax call. I'm using a to_json call in a controller returns data like so: render :text => @item.to_json(:only => [...], :methods => [:foo]) This means, that I have to have foo defined in my Item model as well: class Item def foo "hello #{name}" end end It'd be nice if I could have a DRY method that could be shared in both my views and my models. Usage might look like this: Helper def say_hello(s) "hello #{s}" end User.rb model def foo say_hello(name) end Item.rb model def foo say_hello(label) end View <div class="data"><%= item.foo %></div> Controller def observe @items = item.find(...) render :text => @items.to_json(:only=>[...], :methods=>[:foo]) end IF I'M DUMB, please let me know. I don't know the best way to handle this, but I don't want to completely go against best-practices here. If you can think of a better way, I'm eager to learn!

    Read the article

  • Override to_json in Rails 2.3.5

    - by smotchkkiss
    I've seen some other examples on SO, but I none do what I'm looking for. I'm trying: class User < ActiveRecord::Base def to_json super(:only => :username, :methods => [:foo, :bar]) end end I'm getting ArgumentError: wrong number of arguments (1 for 0). Any ideas?

    Read the article

  • How to control respond_to based on variable in Rails controller?

    - by smotchkkiss
    The dilemma I'm using a before_filter in my controller that restricts access to admins. However, I want to allow access public access to some methods based on request format. See the index method to understand what I'm talking about. items_controller.rb class ItemsController < ApplicationController before_filter :superuser_required layout 'superuser' def index @items = Item.all respond_to do |format| format.html format.js # I want public to have access to this end end def show @item = Item.find(params[:id]) respond_to do |format| format.html end end def new @item = Item.new respond_to do |format| format.html end end # remaining controller methods # ... def superuser_required redirect_to login_path unless current_user.superuser? end end

    Read the article

  • How to identify unique user?

    - by smotchkkiss
    How can you determine if a user is unique or not? I understand there are many ways to do this using cookies, but what about methods that don't use cookies? For example, go to Urban Dictionary and click one of the up/down vote buttons. Even if you delete your cookies and come back to the page, you will not be allowed to cast a vote on the same definition. How do they do this?

    Read the article

  • Rails transaction: save data in multiple models.

    - by smotchkkiss
    my models class Auction belongs_to :item belongs_to :user, :foreign_key => :current_winner_id has_many :auction_bids end class User has_many :auction_bids end class AuctionBid belongs_to :user end current usage An item is displayed on the page, the user enters an amount and clicks bid. Controller code might look something like this: class MyController def bid @ab = AuctionBid.new(params[:auction_bid]) @ab.user = current_user if @ab.save render :json => {:response => 'YAY!'} else render :json => {:response => 'FAIL!'} end end end desired functionality This works great so far! However, I need to ensure a couple other things happen. @ab.auction.bid_count needs to be incremented by one. @ab.user.bid_count needs to be incremented by one @ab.auction.current_winner_id needs to be set to @ab.user_id That is, the User and the Auction associated with the AuctionBid need values updated as well in order for the AuctionBid#save to return true.

    Read the article

  • How to build a JSON response by combining @foo.to_json(options) and @bars.to_json(options) in Rails

    - by smotchkkiss
    First, the desired result I have User and Item models. I'd like to build a JSON response that looks like this: { "user": {"username":"Bob!","foo":"whatever","bar":"hello!"}, "items": [ {"id":1, "name":"one", "zim":"planet", "gir":"earth"}, {"id":2, "name":"two", "zim":"planet", "gir":"mars"} ] } However, my User and Item model have more attributes than just those. I found a way to get this to work, but beware, it's not pretty... Please help... My hacks home_controller.rb class HomeController < ApplicationController def observe respond_to do |format| format.js { render :json => Observation.new(current_user, @items).to_json } end end end observation.rb # NOTE: this is not a subclass of ActiveRecord::Base # this class just serves as a container to aggregate all "observable" objects class Observation attr_accessor :user, :items def initialize(user, items) self.user = user self.items = items end # The JSON needs to be decoded before it's sent to the `to_json` method in the home_controller otherwise the JSON will be escaped... # What a mess! def to_json { :user => ActiveSupport::JSON.decode(user.to_json(:only => :username, :methods => [:foo, :bar])), :items => ActiveSupport::JSON.decode(auctions.to_json(:only => [:id, :name], :methods => [:zim, :gir])) } end end

    Read the article

1