Archive for the ‘Programming’

Development update: Skatr12.26.08

Just a small updated on my development of skatr. It’s almost ready to go for beta release.

If anyone has taken notice, the site is currently down on purpose. I figure I will take it down it gives me more reason to complete my project. The site is being developed using the Merb Framework. After reading some news about Merb being Merged into Rails 3, was actually good I think. Anyways, my project skatr.us will be up live sometime soon, I’m aiming for the first of January, of course this will be beta release and I say beta because things might not be correct on the site, etc..

Posted in Me, Programming, Projects, Ruby, Uncategorizedwith No Comments →

Capturing iSight from Macbook11.04.08

Lately I’ve been writing Objective-C/Cocoa code, and lately I’ve learned how-to capture video from an iSight on a Macbook. It’s actually easy. Here is the code. and I’ve also attached the example application I was writing so you can take a look at it.

[Download Source]
[Download Application]

#import <Cocoa/Cocoa.h>
#import <QTKit/QTKit.h>

@interface MyRecorderController : NSObject {
  IBOutlet QTCaptureView * mCaptureView;
  QTCaptureSession       * mCaptureSession;
  QTCaptureDeviceInput   * mCaptureDeviceInput;
}

- (IBAction)startRecording: (id)sender;
- (IBAction)stopRecording: (id)sender;

@end

@implementation MyRecorderController

- (IBAction)startRecording: (id)sender
{
  // Create a new Capture Session
  mCaptureSession = [[QTCaptureSession alloc] init]; 

  //Connect inputs and outputs to the session
  BOOL success = NO;
  NSError *error;

  // Find a video device
  QTCaptureDevice *device = [QTCaptureDevice defaultInputDeviceWithMediaType:QTMediaTypeVideo];
  if(device) {
    success = [device open:&error];
    if(!success) {
      // Handle Error!
    }
    // Add the video device to the session as device input
    mCaptureDeviceInput = [[QTCaptureDeviceInput alloc] initWithDevice:device];
    success = [mCaptureSession addInput:mCaptureDeviceInput error:&error];
    if(!success) {
      // Handle error
    }

    // Associate the capture view in the UI with the session
    [mCaptureView setCaptureSession:mCaptureSession];

    // Start the capture session runing
    [mCaptureSession startRunning];

  } // End if device
}

- (IBAction)stopRecording: (id)sender
{
  if([mCaptureSession isRunning]) {
     [mCaptureSession stopRunning];
     [mCaptureSession release];
     [mCaptureDeviceInput release];
  }
}

@end

Posted in Mac, Programmingwith 1 Comment →

Apple Drops iPhone Developer NDA On Released Software10.01.08

Apple announced today that it has decided to drop the controversial iPhone developer non-disclosure agreement because it ‘created too much of a burden on developers, authors and others interested in helping further the iPhone’s success.”

via Techcrunch

Posted in iPhone, Mac, Programmingwith No Comments →

RubyCocoa09.12.08

For while now, I’ve been learning Objective-C, and while I’m writing in Ruby more often I figure I would also learn RubyCocoa. I figure I’m going to create a few screencasts on getting started with RubyCocoa and anything I learn with it. If you don’t know what RubyCocoa is, it is described as:

“…a bridge between the Ruby and the Objective-C languages, allowing you to manipulate Objective-C objects from Ruby, and vice-versa. It lets you write full-stack Cocoa applications in Ruby…”

Posted in Mac, Programming, Rubywith No Comments →

LA Ruby Meetup 6/1906.19.08

LA Ruby Meetup was very cool. So I was the first to be at the scene. I helped bring the food to the room since I was in the lobby and greeted by Jody. I meet and greeted all of the LA Times people. Also meet some guy from Yahoo!, sorry I forgot your name already, and one from heroku, BizQuest another from PGP, and another from Experian. As-well as more but I sorta forgot everyones name already… or at least I can’t remember them, yet.

If you’re in the Los Angeles Area check it out.
Yellowpages.com will be hosting LA Ruby Meetup #2 on July 17 2008, so mark that in your calendar. Join the Yahoo Group, LARuby

Posted in Me, Meetup, Programming, Ruby, Ruby On Railswith 1 Comment →

Something in Ruby05.30.08

#!/usr/bin/env ruby

String.class_eval {
  define_method(:translate_to) do |lang|
    text = case lang
           when :spanish
           "Buenos Dias, Como estas hoy?"
           when :english
           "Good Morning, How are you today?"
           else
           "I don't speak any other language."
           end
  end
}

puts "Sentence".translate_to :spanish
# => Prints out "Buenos Dias, Como estas hoy?"

puts "Sentence".translate_to :english
# => Prints out "Good Morning, How are you today?"

puts "Setenece".translate_to :portuguese
# => Prints out "I don't speak any other language."

puts "Sentence"
# => Prints out "Sentence"

So while messing round I made this in Ruby… I’m not sure if it is considered meta programming? Well, it’s just adding a method to the String class. I get confused when to consider things to be meta programming.. Maybe I over think about it.

Posted in Programming, Rubywith 1 Comment →

PHP Snippet03.08.08

Here is a PHP Snippet I wrote. It’s a cool trick to for calling multiple methods in a much simpler way. Inspired by Ruby’s ActiveRecord.

<?php

interface Member {
	function login($username, $password);
	function update($status);
}

class Base implements Member {
	public function login($username, $password) {
		echo "You will be logged in as: {$username} with Password: {$password}\n";
	}

	public function update($status) {
		echo "Your New Status Message is: {$status}\n";
	}

	public function __call($method, array $argv) {
		if(preg_match('/^do_*/i', $method)) {
			foreach(explode("_and_", substr($method, 3)) as $k => $v) {
				$param = array();
				foreach($argv[$k] as $value) { $param[] = "'{$value}'"; }
				$param = join(", ", $param);
				$code = '$this->'. $v ."({$param});";
				eval($code);
			}
		}
	}
}

class User extends Base {

	public function say_hello($message) {
		echo "Message: {$message} \n";
	}
}

$usr =& new User();

$usr->do_login_and_update(array("username", "password"), array("Hello World"));
# Prints the following:
# You will be logged in as: username with Password: password
# Your New Status Message is: Hello World
#

$usr->do_login_and_say_hello(array("username", "password"), array("Hi how are you?"));
# Prints the following:
# You will be logged in as: username with Password: password
# Message: Hi how are you?
#

$usr->do_login_and_update_and_say_hello(array("username", "password"), array("Hello World"), array("Hi how are you?"));
# Prints the following:
# You will be logged in as: username with Password: password
# Your New Status Message is: Hello World
# Message: Hi how are you?
#

?>

Posted in PHP, Programmingwith No Comments →

Ruby Technique: Meta Programming03.02.08

Meta Programming is code that writes code. See the code sample below.
I have made a screencast of this process. View it here

#!/usr/bin/env ruby

class Product
  def initialize(items)
    items.each {|item| Product.product(item) }
  end

  def self.product(item)
    code = %Q{
      def add_#{item}(item)
        @#{item} = [] unless @#{item}
        @#{item} << item
      end

      def display_#{item}s
        @#{item}.each {|item| puts item }
      end
    }
    class_eval(code)
  end
end

class Item < Product
  def initialize(*items)
    super(items)
  end
end

cart = Item.new(:book, :computer, :music)
cart.add_book(:Ruby) # => Add a book to our cart items

cart.display_books # => We want to display All books we have added
puts "\n"

cart.add_computer(:Apple)
cart.add_computer( :D ell)
cart.add_computer(:Sony)
cart.display_computers # => Display All Computers
puts "\n"

cart.add_music(’Modest Mouse‘)
cart.add_music(’Northstar‘)
cart.display_musics # => Display All Music Items

Posted in Programming, Rubywith No Comments →

Lastbridge Stations01.24.08

Added Playlist

New Feature for LastBridge.net – I have added a small list of station you can now select.

Of course more new features are planned ahead.

Posted in Programming, Projects, Ruby On Railswith 1 Comment →

Release: LastBridge01.20.08

Screencast Lastbridge

It is official LastBridge.net is out for public consumption! Again for those who are lost and don’t know what this “LastBridge” is it’s for listening to your last.fm radio stream on the Roku SoundBridge.I have made a screencast on How To use LastBridge. If anyone still needs help or just want to leave your opinions on this project, leave a comment or two. Thanks.Enjoy!

www.LastBridge.net

Posted in Programming, Projects, Ruby On Rails, videowith 29 Comments →

Ruby Code Snippet01.13.08

In Ruby a switch statement looks like this

say = "Hello"

case say
when "Hello" then
	puts "Say Hello"
when "Bye" then
	puts "Say Bye"
end

In PHP a switch statement looks like this


Posted in Programming, Rubywith No Comments →

How to: Objective-C – Part 111.12.07

I finally made a screencast of some objective-c mainly because I myself always figured its much easier to learn something when you see it visually. So that in mind. maybe someone will learn something… or maybe not… whatever…

Posted in Me, Other, Programming, videowith 1 Comment →

Citywaboo Facebook App09.19.07

citywaboo facebook app

After endless days working on the citywaboo facebook app it has finaly been approved. It is now ready for the masses. Add it to your profile, please make sure to register to gain access to all it’s features it has. Don’t forgot to add me to your friends list & leave feedback with any features you would like or how it can greatly be improved. thanks.

Click Here to go to the app

Posted in Me, Programming, Projectswith 1 Comment →

update: phpGAMV07.04.07

Update: phpGAMV, So this 4th of July besides programming I went skateboarding to the park but it was closed which totally sucked and ruined the entire day. So I went skateboarding behind Giant store and it was alright, it was way too hot. I also had time to fix GAMV (Get AOL Music Videos) I fixed the web based version not the application. So have fun using it and enjoi…

http://fernyb.net/phpGAMV

Posted in GAMV, Hacks, Me, Programming, Uncategorizedwith 27 Comments →

MySpace API04.15.07

MySpace does not have an API so while being bored and trying to find something to do. I wrote some code to create a homebrew/homemade API so its the unofficial MySpace API by me. So go ahead and use it do whatever you want with it. A link back to my site would be really cool or at least some credit.

I wrote some documentation for this and you can test it out here aswell. Go to: http://fernyb.net/myspace/api/ It is also available for download so you can use it with your own server.

Posted in Downloads, Hacks, Other, PHP, Programming, Projectswith 16 Comments →

  • Recent Comments

    • Gregorio Schrecongost: obviously like your web-site however you need to check the spelling on quite a few of your...
    • ekstra łazienki: 76. I would like to thank you for the efforts you have put in writing this web site. I’m...
    • djcity record pool: Good day! This post could not be written any better! Reading through this post reminds me of my...
    • Aline Shiner: I in addition to my buddies have already been following the excellent secrets from your website while...
    • Eve: Such superb text! No idea how you wrote this report..it’d take me weeks. Well worth it though, I’d assume. Have...

    Recent Listened to Tracks

    Loading...

Bad Behavior has blocked 114 access attempts in the last 7 days.

eastern-avalanche
eastern-avalanche
eastern-avalanche
eastern-avalanche