Debug Logging in iOS Objective-C Apps – Pt. 2

Hey, it’s me again, sorry for not posting much… Anyway, I recently got fed up with my previous debug logging method and decided to remake it. Before I’d use it like this,

[VAPIHelper debugLog:@"AppDelegate" message:[NSString stringWithFormat:@"authTokenPresent is %@", self.authTokenPresent ? @"YES" : @"NO"]];

Now, with my new improved version it is simply this,

debugLog(@"authTokenPresent is %@", self.authTokenPresent ? @"YES" : @"NO");

As you can see, it is much simpler, handles NSStrings with format inline and shorter! Here’s how it works.
Firstly the macro that defines the debugLog signature is as follows:

#define debugLog(...) [VAPIHelper debugLog:[NSString stringWithFormat:@"%@:%@", @__FILE__, @__LINE__] message:[NSString stringWithFormat:__VA_ARGS__]]

As you can see it has the stringWithFormat builtin, so you don’t need to use that method to construct the string you want to output. Here’s the implementation of [VAPIHelper debugLog:],

+ (void)debugLog:(NSString *)location message:(NSString *)message {
    AppDelegate *delegate = getDelegate();
    if (delegate.debugOn) {
        NSString *debugMsg = [NSString stringWithFormat:@"%@: %@\n", location, message];
        NSLog(@"%@", debugMsg);
        dispatch_async(dispatch_get_main_queue(), ^{
            [delegate.debugTextView setText:[delegate.debugTextView.text stringByAppendingString:debugMsg]];
            NSRange range = NSMakeRange(delegate.debugTextView.text.length - 1, 1);
            [delegate.debugTextView scrollRangeToVisible:range];
        });
    }
}

Firstly I decided to make the getting of the delegate it’s own macro too, the () isn’t needed but makes it clear its a function call, it is simply:

(AppDelegate*)[[UIApplication sharedApplication]delegate]

I got tired of having this ugly snippet everywhere in my code, especially when I forget to typecast the id to an AppDelegate* type, it gives me so many warnings… So I decided to embrace macros to make my life easier and working with my codebases much more pleasant.

As for the rest of the code, it is just checking if debug is enabled on the current build, if so it will construct the string, print it, and display it on my custom UITextView that floats in front of the Parent View Controller, displaying all the debug logging so I don’t need to ssh for socat. Now that I think about it, I think ill stub out the debugLog function entirely if the build isn’t compiled with DEBUG set. It’d be better for security yeah. Anyway that’s all for now 😀

Posted in Uncategorized | Leave a comment

The Fear of Public Speaking

So in my current catalog of university courses, public speaking is one of them. This week we had to come prepared to class with a monologue, song or poem to present in front of the class. Luckily we did not have to memorize our selection however we were graded based on the several techniques we learned during class such as look at the audience, eye contact, and other things such as to not present yourself as stiff and dress appropriately.

 

As people went up to present, I was internally counting the amount of people and calculating the chances that I’d be called to go up lol. I was more so focused on calming myself down, reassuring myself it’d be ok. Surely if these people going up can muster up the courage to present their piece, I can too, right? That was the question I was brewing my nerves over the entirety of my waiting period.

 

As soon as I was called, it was like a different me took over. I immediate got up and went over to the podium, however now that me was gone as I faced my audience. I read in my textbook that approximately 30 seconds after starting a speech, your nerves calm down. During my first 30 seconds, I was more preoccupied with making sure I looked at my audience rather than making sure I made no mistakes in my presentation. But god damn, after those 30 seconds, my nerves were gone. It’s important that what you present, is something you are passionate about.

 

It was magical, I was more focused on making sure I emphasized what I needed to emphasize, that I portrayed the emotions I wanted to portray. If you are wondering what my presentation was about, it was a sonnet about Pokemon, the trading card game in particular lol. The sound of the applause I think sort of made it worth it. I wouldn’t say entirely but with this experience I think I’d be less likely to be nervous for next time.

 

My point being is, if you don’t put yourself out there due to nervousness, you’ll never break out of your shell, break your nervousness. It’ll stick with you in everything you do in the back of your mind. The thought of public speaking would make me nervous, a few weeks in and that’s mostly gone. I have a good feeling I’ll pass this class with at least an A. We’ll see. Thank you for reading this and have a great day :-).

 

Oh and watch Zom 100, it seriously is a pretty great comedy anime.

Published from BlogJet on Windows 2000

Posted in Uncategorized | Leave a comment

Little Free Libraries

Today I want to write to you about Little Free Libraries.

First, let’s start off with how I came to know them myself. Picture this, you are walking down a residential road in a city. The sun is shining down on you. You might be sweating in this blistering heat. Don’t ask me where I’m going with this but uh, you spot a blue wooden box at eye level across the street perched on a metal fence.

Painted a refreshing ocean blue with a windowed door providing a glimpse at the various books inside. There’s a note on the side of the box that says “take a book, share a book”.

Being in a city you question how it is filled with book instead of being empty because the stereotypical midnight robbers vandalized and stole them. It is New York City after all. Regardless, you find it so intriguing that you tell yourself you’ll be back one day with a book entow.

Thank you sticking with me so far, It isn’t everyday I get to write things like this. In the end I did end up going back to that box and even took a trip to another one nearby to me to exchange books.

Those boxes are Little Free Libraries. They exist as a way for the community they’re in to exchange books and therefore knowledge. Personally I like reading books and to be honest that day I went I was just bored.

In exchange for Fahrenheit 451 and Ava and Pip I took Designing Your Life and The Orphan’s Tale. I’ll read them soon and maybe write a review for fun.

That’s all for today’s post. Thank you for reading and I highly encourage you to find one of those boxes yourself and exchange some knowledge with your community.

I totally didn’t write this in my English class instead of writing about the actual assignment (¬‿¬)

Posted in Uncategorized | Leave a comment

First Impressions at City Tech NYC

Following my 1 year hiatus from education after high school, I finally got off my ass and applied to a University, that would be City Tech on Jay Street, NYC. I’m writing this to give you my first impressions after my first week attending.

1. The campus is bigger than any school I’ve ever been to.

I guess that’s a given but I haven’t been to a universities’ campus before so it was huge to me.

2. They seriously need a map booklet or something.

I’ve gotten lost my first 3 days in a row. Looking at a post on the wall in the main building would tell you that the library is in the “Atrium Building”, I think they meant across the atrium instead of calling it a building… Also the library spans over 4 floors apparently, it would be easy to find a place in a corner somewhere to do some studying without being noticed. By the way if the classroom number starts with an L, it’s because the classroom in the building that houses the Library. They seriously need something that says this.

3. I do think the bridge between the main building and library building is beautiful though. Image of inside of atrium

4. They need more elevators (;_;) 6 isn’t enough for the over a thousand? Students who need to go up 10 stories…

5. The entrance has these futuristic machines that you can place your ID card on and they open like the MTA turnstile. Theoretically someone could enter behind someone without scanning because the closing delay is so large, I haven’t tested this though lol.

6. The 5 professors I have are all lovely people, except my Public Speaking professor, she has main character syndrome (-_-)

Anyway I’m happy with my experience so far and will post photos in the gallery soon to show off the surrounding area and some parts of the inside.

Posted in Uncategorized | Leave a comment

Debug Logging in iOS Objective-C Apps

So recently I’ve been working on Veteris (My App Store client/server) and YewTube (My YouTube client) and needed a better way to add logging to my apps without it logging on release builds.

Whilst searching for a solution I found a ancient Ars Technica article pointing to this link, Of course the links on the article are dead but I was able to extract enough information to get it working for me. Here’s how I implemented it.

So first, in a class you’d like to use, I used the AppDelegate you just need to add these lines to your header.

#ifdef DEBUG
#define DebugLog(args...) _DebugLog(__FILE__,__LINE__,args);
#else
#define DebugLog(x...)
#endif

@interface YourClass: NSObject
void _DebugLog(const char *file, int lineNumber, NSString *format,...);
@end

And you need to add these lines to the implementation.

void _DebugLog(const char *file, int lineNumber, NSString *message,...) {
  NSString *string = [[NSString alloc] initWithUTF8String:file];
  NSLog(@"%@:%d: %@", string, lineNumber, message);
}

Of course, there is probably a better way to write this implementation but I’m content with this. You can call the function like so.

DebugLog([NSString stringWithFormat:@"VAPIDeviceString = %@", [VAPIHelper getVAPIDeviceString]]);

Thank you for coming to my TED Talk and I hope someone finds this useful now, or in the future.

Posted in Uncategorized | Leave a comment

The ThinkPad R51 Mandrake Experience – Part 2

Prologue

First let me start off by saying, Thank You to all who have read Part 1 and visited my websites since the time of publish! School has me busy and stressed over finals, I haven’t been able to work on much and the blog included. However I do have a break coming up, so I should be able to write more posts :smiling:.

WiFi Chip Pain

Before my friend shipped me the ThinkPad the WiFi chip was replace with a 5Ghz Intel 4965agn. The issue with this is that IBM like all other laptop OEMs at that time enforces restrictions on which specific chips you can use in their laptops. Simply put, the ThinkPad will NOT boot at all when the incorrect WiFi chips is inserted. Luckily there is a hacky way to bypass this restriction by writing to a BIOS variable stored in CMOS from Linux. You can find instructions here. After booting into Linux without the chip inserted you can compile and run this program and break free from IBM’s shackles. I only needed to do this again because I was stupid and let the battery run dry.

MultiMedia Playback

Since I’ll be using this laptop for a week I need to find a way to play my music obviously. After some scouring on Google I found some old repositories and took the liberty to mirror them. You can find the mirror here. I have also mirrored other repositories such as the PLF repos, you can find them in the root websites directory. I installed xmms + the flac plugin and was up in running in about 5 minutes. I usually use a media server to stream my music but the old browser cannot handle it. I rsync’d my whole library onto a flash drive and all was well.

Communication

In order to be able to talk to my friend and share my pain, I needed a way to speak to him without using my phone or other devices. I decided to find something age appropriate, 2 programs fit this bill. Mumble and Teamspeak, I had used Mumble before so I decided on Teamspeak for the sake of trying something new. Using the Wayback Machine I was able to download the old Linux server and client binaries. Having that old piece of software running on my modern server probably wasn’t such a good idea security wise but I had to do what I had to do (it’s no longer up don’t bother). Setting it up was rather easy, just port forward its ports and edit the self-explanatory configuration file and done! We had some troubling connecting to it but it turned out to be firewall issues. Speaking to each other with potato microphones and in 64kbps was great.

Conclusion

At the end of week we were freed from 2006 and were able to use our main machines again. I honestly loved every bit of time traveling back into 2006 except for the weight of the machine. This things a brick, my friend on the other hand complained every day about something new. I, however do not recommend this to anyone because of the browser situation and many other factors that will require you to be content with limited internet connectivity.

Posted in Uncategorized | Leave a comment

Test!

This is a test from Windows Server 2008 R2, sent over the internet via BlogDesk to this WordPress Instance!

BlogDesk-button

Posted in Uncategorized | Leave a comment

The ThinkPad R51 Mandrake Experience

A very “gracious” friend forcefully donated me an upgraded ThinkPad R51 and then made ME pay for the shipping along with some of the upgrades. So for my first blog post, I decided that I’d review this laptop and write about my experiences with a fully setup time period correct Linux install on it.

First, let’s get into what the ThinkPad R51 is,The ThinkPad R51 can be best described as a brick with an amazing cover…
ThinkPad R51 Lid
It is quite literally a brick and those were my honest first impressions. However, is it a very peculiar brick once you open it up.

The lid is held on by a single latch, I thought it would be a weak latch but it was a pretty nice feeling. The switch is even recessed and has a nice texture to it.
Laptop Keyboard with trackpad at the bottom
Inside the laptop, you will find the gorgeous and massive IPS display. For a laptop from 2005, it’s crazy I know. It has a resolution of 1400×1050.

At the top of the LCD panel there is a bump that houses the “ThinkLight”, with the press of Fn + PgUp you can have your own 1980s CRT flavored light illuminating your keyboard! Below the display is of course the keyboard in all its clicky glory. (seriously if you have one of these give it a nice click for me!) This thing is what dreams are made of for a membrane keyboard. I can forgive it for not having a Numpad because of how compact it is.
In the lower middle of the keyboard is the “TrackPoint IV”. What’s new with the IV model is that you can tap it for a left click. Although I’ve never used the TrackPoint as I find it to be inaccurate. That’s probably my excuse for not even attempting to use it.
If you could tap to click it I’m not sure why there are dedicated buttons to be used with it above the trackpad. And about that trackpad, for today’s standards, it’s comically small lol.
Above the keyboard is the nice and shiny power button, it’s only shiny to entice you to click it, don’t do it, or at least save your work before you do. Next to that are the media keys and the “ACCESS IBM” key. I’m sure it had a purpose under Windows, it’s most probably useless though. Of course, we can’t forget the retro RGB IBM logo at the bottom right corner.

Now on to the plethora of ports, it has everything you could need in 2005.

1x VGA port
1x S-Video port
2x USB 2.0 ports
1x IEEE 1394/FireWire 400 port
1x pcmcia card slot \
In the same slot!
1x express card slot /
1x 3.5mm headphone jack
1x 3.5mm microphone jack – Connected via the AC’97 codec
1x Gigabit Ethernet jack
1x Modem jack
1x IrDA 1.1 port
1x Kensington Lock slot
Mine came equipped with the DVD + CD combo drive.

Here is the slightly disappointing part, it comes with a Pentium M (Banias or Dothan). Make sure you get the Dothan version, the Banias Pentium M’s have
1. Less L2 Cache
2. Slower Front Side Bus Speed
3. Less efficient
4. No PAE, PAE is required for running more modern operating systems
There is like 10 different model configurations for this laptop so be sure you are getting what you want before you buy. Contact your seller, etc.
The best part about my model is the screen and the Radeon 7500 card connected via the AGP interface, there is no way I will have issues with a fglrx card 🙂

Upon first boot you are greeted with IBM’s bloated XP install, sure the themes look cool but they get old seriously quick. I’m not much of a Windows user so I’ll be installing Linux on it with a fresh copy of XP on the first partiton.

I have a 60GB hard drive to work with, here’s my setup.

First Partition: Windows XP 29GB
Rest: Let Linux handle it

If we are going to install Linux the first thing to do is choose what distro. My goal is to have a time appropriate installation, so I choose the Ubuntu of 2005, Mandrake Linux 10.2 or as it was going to be known as Mandriva Linux 2005 Limited Edition. A mouthful for the Mandriva name.

I proceeded to firstly install a fresh copy of Windows XP. I had a Windows XP SP1a reinstallation disc for a old Dell machine that I used. Everything went smoothly except for the part where upon first boot it had literally no drivers whatsoever. I don’t know what I expected but I at least needed working ethernet.
I had to use a flash drive to copy over the drivers, after that, THEN it went smoothly. I installed WinAMP and all the other classic programs. Finally it was time to burn my Mandrake ISOs, provided here: http://ftp.twaren.net/Linux/Mandrake/official/iso/10.2/i586/. My first instinct was to download the DVD and save myself some time but it doesn’t work like that apparently because when I put in my DVD all I heard was a whirring noise followed by it stalling. It constantly trying to respin up but failing.
Either
1. My DVD combo drive is a sham or
2. My DVDs are too new lmao
I wasn’t going to fish out a external DVD drive just to have more problems so I downloaded the 3 ISO CD set and burned away.

Now we are off to the races, we won’t be coming in first place though.

Installation was your average affair, choosing software selection (I chose everything but server stuff), waiting for it to install the packages and setting up users.
Only issues I had was supertuxkart and tkinter failing to install. I just selected the option to ignore it and continue.
At the hardware configuration page I chose to use the proprietary fglrx drivers and setup my monitor resolution.

Upon first boot up, it was breathtaking. On my modern systems I use trinity desktop sometimes because of how much I love KDE 3 and the integration it had compared to gnome which always tended to break and crack under pressure (applying gtk themes and what not). KDE 3 had none of these issues that I’ve encountered. The boot up experience and the intro to the desktop is truly an artifact of its time. You won’t be finding any flat icons here, only icons that make sense as to what it represents.
I wasn’t even sure what to do first, I ended up poking around the main menu and finding my favorite Linux game of this time period.
Meet frozen-bubble

Everyone’s favorite bubble tossing game? I don’t know how you would describe it but the music is amazing and the gameplay and altogether its an experience you can easily sink hours into trying to beat your high score. If you haven’t tried it before I recommend you install it now.

Everything (almost) just worked, which is surprising for 2005 Linux. I’ll go over my goals/plans in the next blog post, how I ended up using this thing as my main computer for a week and how I fixed one pesky issue 😉

Until next time, adieu.

Posted in Uncategorized | 2 Comments

Hello world!

Welcome to WordPress. This is your first post. Edit or delete it, then start writing!

Posted in Uncategorized | 4 Comments