Search Results

Search found 29 results on 2 pages for 'ryeguy'.

Page 1/2 | 1 2  | Next Page >

  • Is there a good reason I shouldn't use a java applet for a game?

    - by ryeguy
    I want to make a multiplayer browser-based game. The nice thing about using an applet is that I can make the client and the server in the same language (java/closure/scala/etc). I know there's html5 and javascript, but server side javascript isn't as mature as the jvm platform and browser support is still kind of flaky. Applets don't seem to be widely used (except for Runescape), but is there a reason they're unsuitable or is it just because of the bad reputation they developed in their infancy?

    Read the article

  • Why can't I unblock postgres with shorewall?

    - by ryeguy
    I can't seem to unblock the port needed for postgres using Shorewall. I am developing a PHP app on my windows machine here, and then I upload it on my linux box to actually use it. The linux box runs the php files as well as hosts the db server. Since I need it working from both machines, in my PHP code I am referring to the database as the full IP instead of localhost. I can easily connect to postgres from my windows machine, but ironically, my PHP app can't connect to postgres even though it's on the same box. Here's what I have in /etc/shorewall/rules: #macro/action src dest PostgreSQL/ACCEPT net $FW PostgreSQL/ACCEPT loc $FW PostgreSQL/ACCEPT loc dmz PostgreSQL/ACCEPT net dmz PostgreSQL/ACCEPT loc net PostgreSQL/ACCEPT dmz $FW PostgreSQL/ACCEPT dmz loc PostgreSQL/ACCEPT dmz net PostgreSQL/ACCEPT dmz dmz Clearly I have a ton of crap there. The first line is all I needed to make it allow a connection from my windows machine. All the lines after it are me just trying everything to get it to work. What am I missing?

    Read the article

  • Why create many partitions?

    - by ryeguy
    I have noticed that when installing Ubuntu some people create multiple partitions for directories. Like one for root, one for home, one for boot. What is the advantage to doing this over installing them all on one partition, assuming there is only one hard drive?

    Read the article

  • What makes a laptop battery specific to a model?

    - by ryeguy
    I have an old Toshiba laptop (pentium 4) whose battery just crapped out. Looking at the battery, it says it's a PA3251U. Looking online, this thing is going for about $100! I don't want to spend probably 50% of this machine's value on a battery replacement! My question is: what makes a laptop battery specific to a model? Do I really only have this one battery to choose from, or can I look for any battery that matches some certain attributes (like number of cells, voltage, etc)?

    Read the article

  • How can one domain route to an always-changing pool of servers?

    - by ryeguy
    I'm sure this is an easy solution, I'm just not too familiar with how DNS works or if that's even related to this problem. If I'm running a web service on amazon ec2, distributed across many instances, how can I make it so a single domain name can be used to access the entire pool of servers, which will be changing from time to time? Since the instances may be present one second but gone the next (and vice versa), I need a way to randomly pick an active member of the cluster to route to. The updates would have to be instantaneous. Is this even possible, with dns caching and all?

    Read the article

  • C# Begin/EndReceive - how do I read large data?

    - by ryeguy
    When reading data in chunks of say, 1024, how do I continue to read from a socket that receives a message bigger than 1024 bytes until there is no data left? Should I just use BeginReceive to read a packet's length prefix only, and then once that is retrieved, use Receive() (in the async thread) to read the rest of the packet? Or is there another way? edit: I thought Jon Skeet's link had the solution, but there is a bit of a speedbump with that code. The code I used is: public class StateObject { public Socket workSocket = null; public const int BUFFER_SIZE = 1024; public byte[] buffer = new byte[BUFFER_SIZE]; public StringBuilder sb = new StringBuilder(); } public static void Read_Callback(IAsyncResult ar) { StateObject so = (StateObject) ar.AsyncState; Socket s = so.workSocket; int read = s.EndReceive(ar); if (read > 0) { so.sb.Append(Encoding.ASCII.GetString(so.buffer, 0, read)); if (read == StateObject.BUFFER_SIZE) { s.BeginReceive(so.buffer, 0, StateObject.BUFFER_SIZE, 0, new AyncCallback(Async_Send_Receive.Read_Callback), so); return; } } if (so.sb.Length > 0) { //All of the data has been read, so displays it to the console string strContent; strContent = so.sb.ToString(); Console.WriteLine(String.Format("Read {0} byte from socket" + "data = {1} ", strContent.Length, strContent)); } s.Close(); } Now this corrected works fine most of the time, but it fails when the packet's size is a multiple of the buffer. The reason for this is if the buffer gets filled on a read it is assumed there is more data; but the same problem happens as before. A 2 byte buffer, for exmaple, gets filled twice on a 4 byte packet, and assumes there is more data. It then blocks because there is nothing left to read. The problem is that the receive function doesn't know when the end of the packet is. This got me thinking to two possible solutions: I could either have an end-of-packet delimiter or I could read the packet header to find the length and then receive exactly that amount (as I originally suggested). There's problems with each of these, though. I don't like the idea of using a delimiter, as a user could somehow work that into a packet in an input string from the app and screw it up. It also just seems kinda sloppy to me. The length header sounds ok, but I'm planning on using protocol buffers - I don't know the format of the data. Is there a length header? How many bytes is it? Would this be something I implement myself? Etc.. What should I do?

    Read the article

  • What's the point of some of shoulda's macros?

    - by ryeguy
    I think shoulda is really neat, but what I don't understand is why some of the macros exist, such as: should_validate_uniqueness_of :title should_validate_presence_of :body, :message => /wtf/ should_validate_presence_of :title should_validate_numericality_of :user_id I'm relatively new to testing, but what purpose do these serve? They're almost an exact mirror of the same validations that happen in the model. For example, what exactly do you accomplish by going into your model and writing validates_uniqueness_of :title and then writing a test that says should_validate_uniqueness_of :title?

    Read the article

  • Why is "rake tests" running an empty suite when I use shoulda?

    - by ryeguy
    So here is my test suite: class ReleaseTest < ActiveSupport::TestCase should_not_allow_values_for :title, '', 'blah', 'blah blah' should_allow_values_for :title, 'blah - bleh', 'blah blah - bleh bleh' def test_something assert true end end Shoulda's macros generate 5 tests, and then I have test_something below (just to see if that would matter), totalling 6 tests. They all pass as you can see below, but then it runs a 0-test suite. This happens even if I completely empty out ReleaseTest. This problem only exists if I have config.gem 'shoulda' in my environment.rb. If I explicitly do require 'shoulda' at the top of my tests, everything works fine. What would be causing this? /usr/bin/ruby -e STDOUT.sync=true;STDERR.sync=true;load($0=ARGV.shift) /var/lib/gems/1.9.1/bin/rake test Testing started at 6:58 PM ... (in /home/rlepidi/projects/rails/testproject) /usr/bin/ruby1.9.1 -I"lib:test" "/var/lib/gems/1.9.1/gems/rake-0.8.7/lib/rake/rake_test_loader.rb" "test/unit/release_test.rb" Loaded suite /var/lib/gems/1.9.1/gems/rake-0.8.7/lib/rake/rake_test_loader Started ...... Finished in 0.029335778 seconds. 6 tests, 6 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed /usr/bin/ruby1.9.1 -I"lib:test" "/var/lib/gems/1.9.1/gems/rake-0.8.7/lib/rake/rake_test_loader.rb" /usr/bin/ruby1.9.1 -I"lib:test" "/var/lib/gems/1.9.1/gems/rake-0.8.7/lib/rake/rake_test_loader.rb" Loaded suite /var/lib/gems/1.9.1/bin/rake Started Finished in 0.000106717 seconds. 0 tests, 0 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 0% passed Empty test suite.

    Read the article

  • What does "render @collection" do?

    - by ryeguy
    I'm trying to learn Rails better by looking at example applications, and while looking at this line of the source of railscasts.com, I noticed it does this: <div class="episodes"> <%= render @episodes %> </div> What exactly is going on here? Why isn't this documented on the render function? Or is it?

    Read the article

  • Using comet with PHP?

    - by ryeguy
    I was thinking of implementing real time chat using a PHP backend, but I ran across this comment on a site discussing comet: My understanding is that PHP is a terrible language for Comet, because Comet requires you to keep a persistent connection open to each browser client. Using mod_php this means tying up an Apache child full-time for each client which doesn’t scale at all. The people I know doing Comet stuff are mostly using Twisted Python which is designed to handle hundreds or thousands of simultaneous connections. Is this true? Or is it something that can be configured around?

    Read the article

  • How can a program be detected as running?

    - by ryeguy
    I have written a program that is sort of an unofficial, standalone plugin for an application. It allows customers to get a service that is a lower priced alternative then the vendor-owned one. My program is not illegal, against any kind of TOS, and is certainly not a virus, adware, or anything like that. That being said, the vendor of course is not happy about me taking his competition, and is trying to block my application from running. He has already tried some tactics to stop people from running my app alongside his. He makes it so if it is detected, his app throws a fake error. First, he checked to see if my program was running by looking for an open window with the right title. I countered this by randomizing the program title at startup. Next, he looked for the running process name. I countered this by making the app copy itself when it is started as [random string].exe and then running that. Anyways, my question is this: what else can he do to detect if my program running? I know that you can read window text (ie status bar, labels). I'm prepared to counter this by replacing the labels with images (ugh, any other way?). But what else is there? Can you detect what .dlls a program has loaded? If so, could this be solved by randomizing the dll names before loading them? I know that it's possible to get a program's signature in memory and track it that way (like a virus scanner), but the chances of him doing that probably aren't good because that sounds pretty advanced. Even though this is kinda crappy of him to be doing, its kind of fun. It's like a nerdy fist fight. EDIT: When I said it's a plugin, that is just the (incorrect) term I used. It's a standalone EXE. The "API" between my program and the other is mine is simply entering data into the controls (like textboxes, etc).

    Read the article

  • Why is Rails is trying to rerun migrations on production?

    - by ryeguy
    On my server when deploying the app for the first time, I ran rake db:setup which loads my entire migration history from schema.rb. Now I have more stuff I want to add, but when I run rake db:migrate on my server I realize it's trying to run my very first migration, which is failing since the table obviously exists. Examining the schema_migrations table on my production server, I realize it only has one entry in it, which is the migration that was the most current at the time of the initial deployment. Isn't it supposed to have the entire migration history in it? If so, what caused this? If not, why is it doing this?

    Read the article

  • What's an elegant way to conditionally add a class to an HTML element in a view?

    - by ryeguy
    I occasionally have to add a class to an html element based on a condition. The problem is I can't figure out a clean way of doing it. Here's an example of the stuff I've tried: <div <%= if @status = 'success'; "class='ok'"; end %>> some message here </div> OR <% if @status == 'success' %> <div class='success'> <% else %> <div> <% end %> some message here </div> I don't like the first approach because it's crowded looking and hard to read. I don't like the second approach because the nesting is screwed up. It'd be nice to put it in the model, (something like @status.css_class), but that doesn't belong there. What do most people do?

    Read the article

  • How do I test controllers and views?

    - by ryeguy
    I'm using rails for the first time, and I love how test-oriented it is and how it encourages you to write tests. I'm just having a hard time figuring out what I should be testing when I test controllers and views. I know that you should test redirects and authorization in the controller tests, but what else? And what should go in view tests? If I'm "following the rules" and only putting loops, conditionals, and echoes in my views, then what is there left to test?

    Read the article

  • Why are my rails tests so slow?

    - by ryeguy
    Is it normal for my test suite to take 5 seconds just to launch? Even when running an empty suite it still takes this long. Is it because it's firing up a new instance of rails on each run? If so, is there anyway to keep it persistent? I'm using Test::Unit with Shoulda.

    Read the article

  • How can I override the attribute assignment in an active record object?

    - by ryeguy
    I know you can do this with virtual attributes, but what if the column actually exists? For example, my model has a raw_topic column. When raw_topic is set, I want artist and song_title to be set based off of raw_topic's contents. Ideally, I'd like to override the raw_topic= method, but rails doesn't seem to like that. What's the proper way of doing this? Is a callback the only way?

    Read the article

  • Should I be using callbacks or should I override attributes?

    - by ryeguy
    What is the more "rails-like"? If I want to modify a model's property when it's set, should I do this: def url=(url) #remove session id self[:url] = url.split('?s=')[0] end or this? before_save do |record| #remove session id record.url = record.url.split('?s=')[0] end Is there any benefit for doing it one way or the other? If so, why? If not, which one is generally more common?

    Read the article

  • Rails is caching when I don't want it to. Why?

    - by ryeguy
    Rails is caching the index method of one of my controllers. It's a very simple application and only has like 2 controllers and a handful of actions each. The weird thing is I don't have any caching in my application at all, at least not explicitly. The pages get uncached if I restart passenger. Does rails do some kind of automatic page caching? There are no files in the public directory The page is returning a 200 header I have no caching blocks in my views (I use haml, if that matters) I have no action, controller, or page caching defined The request is hitting rails, verified by the production log I have the following in my production.rb: config.cache_classes = true config.action_controller.consider_all_requests_local = false config.action_controller.perform_caching = true config.action_view.cache_template_loading = true

    Read the article

  • Why is rails setting ":null => false" on all my columns in schema.rb?

    - by ryeguy
    Even if I never specify :null => false in my migrations that initially add columns to tables, rails still generates code in schema.rb that specifies the columns as having :null => false. Why is this? If I develop on my box, and then use rake db:schema:load on my production box, I'm going to get very different behavior! Edit: Even if I delete schema.rb and run rake db:schema:dump, it still puts :null => false on the new schema even if it isn't defined like that in the actual database. It seems it can't tell whether or not a column is marked as allowing nulls. I'm using SQLite if that helps.

    Read the article

  • C# documentation generator?

    - by ryeguy
    Is there any kind of documentation generator for C#? Like something that would put the xml-ish documentation right above the method/class declarations? Is there a tool or is it tucked away somewhere in VS 2008?

    Read the article

  • How can I return something early from a block?

    - by ryeguy
    If I wanted to do something like this: collection.each do |i| return nil if i == 3 ..many lines of code here.. end How would I get that effect? I know I could just wrap everything inside the block in a big if statement, but I'd like to avoid the nesting if possible.

    Read the article

1 2  | Next Page >