Archive for the ‘Programming’

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(:Dell)
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 25 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 26 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 →

Net_Growl = PHP + Growl02.17.07

So today I was messing around with php & growl. So here is tip for getting started. First download growl if you dont have it already. Next install the php pear package

Once you have all the set-up. Go into your System Preferences and go into the Network tab in the growl settings. While in the Network tab make sure you click on “Listen for incoming notifications” & “Allow remote application registration” and set the password. I set my password to “123456″

Now type this piece of code.

The first time you run the file through your web browser OSX will prompt you with a message.
Just Click Always Allow unless you have a reason not to.

So once you have done everything from above you should now see a message like the one below.

Wasn’t that cool! so here are the all my files I used.
Download: php-growl.zip

mamasam.com

Posted in Mac, Other, PHP, Programming, Uncategorizedwith 5 Comments →

GAMV02.10.07

Sun, Feb 11, 2007 - Update: GAMV-PHP works now. GAMV Application still does not work but I really don’t have time to fix it, I’m busy working on other projects. If you want to you can fix it. Here is the source code. gamv source code its made in RealBasic.

Update: A fix for this will be available tomorrow.

GAMV (Get AOL Music Videos) is an app to get and watch aol videos. simple as that.
Mac: GAMV.zip | Windows: GAMV.exe.zip | Linux: GAMVx.zip

Posted in Downloads, GAMV, Mac, Programming, Projectswith 35 Comments →

SQL Injections01.30.07

So I found this site its kinda funny. They have major issues with their sql queries. check it out for yourself.
theconcertgoer.com

Posted in Hacks, Programming, Uncategorizedwith 8 Comments →

Listen to Last.fm with the Roku SoundBridge01.14.07

Update: Listen to your Last.fm streaming radio on the Roku SoundBridge Using LastBridge.net.
LastBridge.net makes it really simple to listen to your last.fm music on the soundbridge. If that is what you are looking for then check out it out! www.LastBridge.net.

Updated Post

So a while ago, maybe 7 months ago I bought the Roku SoundBridge and I do like it. Recently I have been listening to a lot of last.fm to my personal radio / loved tracks. So while listening to last.fm I didn’t always want the computer to be on so I googled to see if there was any solutions. I found one but it was some kinda server written in python. I didn’t test it but from the read me file it seems you need to have your computer turned on. Which is what I am trying to avoid. Now I came up with my solution.

It’s basically a controller. You can use your a PSP that is if you have one, I do so I use that to control it when I am away from my computer. It uses a playlist file to play your last.fm radio stream. So not only can you use this playlist file with the roku soundbridge but also with other media players and its controlled via a web based controller.

It is written in PHP.
You can download it here. last.fm-for-roku-soundbridge-etc.zip

It’s super easy to setup. Just open the config.php file with a plain text editor and insert your username and password. The password need to be in md5. With Mac OSX you can open up Terminal and get your md5 that way. Type this in the termnial.
md5 -s [your_password]
of course replace [your_password] with your actual password and it then will generate an md5. If your on windows I don’t know how you would get an md5 but I found this app useful to get the md5sum.
fourmilab.ch/md5/ .zip file contain the md5.exe. Enjoy.

Oh yeah before I forget you will need a web server with php installed and with cURL. Thats it.
If you need a free php web host then here is a list 0php.com/free_PHP_hosting.php or you can always just search for one, although it’s always best to just buy web hosting its not expensive.

Posted in Downloads, Hacks, Last.fm, Programming, Projects, Uncategorizedwith 14 Comments →


  • I am Fernando Barajas. Mostly known has FernyB.

  • Recent Comments

    • wat: hey fernyb i was just informed that the new pwnage tool is releasing tomrow with installer 4 and the updated...
    • Gaisce1: Fernando, Would it be possible to have the ‘current track’ title displayed in LastBridge as well...
    • Pip: Even after using TextWrangler and inputting my last.fm username there VLC gives me this error message: main: no...
    • Pip: I can give you a call from my phone, if you don’t mind providing some live help. I have copied the file as...
    • Pip: Thanks Fernando for your prompt reply! I am glad you are also a Mac user, but I have to confess that your blog...

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

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