Archive for febbraio, 2012
18
feb

Hi nerdz,
today i’ll show you how to easily control remotely your room with a stupid motion detector, a piro sensor (or you can use other sensors, like ultrasonic, infrared, light sensor, pressure, etc etc…) and two lines of PHP code and C.

* Useful if you want to know if anyone enter in your room and the time that remains there! *


You can get this sensor from AirWick deo! :)

How it works?
Your piro sensor, when detect a motion, notify arduino, that was programmed to send to serial port a value (“m” or “n”).
These value are interpreted by a serial reader (c# program, objective-c, java, c++, or somethig else) that call a PHP page that send email if is enabled sending mode.
Second php page, permit you to control arduino (enable/disable/show logs/clear all).

Steps:
Connect your piro sensor to arduino, easy way, like this:
Arduino Connecting Piro Sensor

After that, write your simple arduino code:

Continue reading “[Arduino] Room Spy Email Notificator” »

FacebookTwitterDeliciousLinkedInGoogle BookmarksNetlogGoogle GmailMySpaceGoogle ReaderShare

, , , , , , ,

18
feb

Well, done!
Developer preview 1 installed successfully.

It works.

FacebookTwitterDeliciousLinkedInGoogle BookmarksNetlogGoogle GmailMySpaceGoogle ReaderShare

, , ,

15
feb

Hi all!
By chance i founded this tricks that permit to show a “Dictionary definition” for the selected word in a UITextField on a hidden menu.

Menu contains these actions:

  • cut
  • copy
  • select
  • select all
  • paste
  • suggest
  • definition
  • indent left
  • indent right
  • It’s a cool tricks, that show an hidden menu with a lot of options, that i never see before!

    Watch this:


    iOS Hidden Menu features
    iOS Hidden Menu features
    iOS Hidden Menu features

    And this is the dictionary definition for pizza on simulator:


    iOS Hidden Menu features

    How?

    Continue reading “[Objective-C] Show dictionary definition on UITextField” »

    FacebookTwitterDeliciousLinkedInGoogle BookmarksNetlogGoogle GmailMySpaceGoogle ReaderShare

    , , , , ,

    15
    feb

    Follow these simple steps, and after 1 minutes you’ll print your code generated pdf from your iphone!

  • Create a XIB with the size of your pdf (in my case is 612×792) and add all UILabel or UIImage that you need.
  • Import CoreText Framework and include in your project.
    Remember that CoreText.framework works only with iOS >= 3.2 for ipad and iphone 4.0.
  • Add these methods declarations in your .h:
  • 1
    2
    3
    4
    5
    6
    7
    8
    + (void) drawPDF:(NSString*)fileName;

    + (void) drawLabels;
    + (void) drawText;
    + (void) drawText:(NSString*)textToDraw inFrame:(CGRect)frameRect;
    + (void) drawLineFromPoint:(CGPoint)from toPoint:(CGPoint)to;
    + (void) drawLogo;
    + (void) drawImage:(UIImage*)image inRect:(CGRect)rect;

    Now, implement all methods in your class…

    Continue reading “[Objective-C] Print code generated PDF with AirPrint” »

    FacebookTwitterDeliciousLinkedInGoogle BookmarksNetlogGoogle GmailMySpaceGoogle ReaderShare

    , , , , , , , , ,

    14
    feb

    Don’t see video? Use this: http://youtu.be/WlEzvdlYRes

    FacebookTwitterDeliciousLinkedInGoogle BookmarksNetlogGoogle GmailMySpaceGoogle ReaderShare

    01
    feb

    Suppose that we have a ViewController.h and .m like this:

    1
    2
    3
    4
    5
    // ViewController.h
    #import UIKit/UIKit.h

    @interface ViewController : UIViewController
    @end
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    // ViewController.m
    #import "ViewController.h"
    #import "SetValue.h"

    @implementation ViewController
    - (void)viewDidLoad
    {
      [super viewDidLoad];

      [SetValue SetTheValue:@"a string"];
    }
    @end

    And a class called SetValue, with two methods.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    // SetValue.h
    #import Foundation/Foundation.h

    @interface SetValue : NSObject { }

    + (void) SetTheValue:(id)Obj;
    - (void) MySelector:(id)Obj;

    @end
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    // SetValue.m
    #import "SetValue.h"

    @implementation SetValue

    + (void) SetTheValue:(id)Obj
    {
      [self performSelectorOnMainThread:@selector(MySelector:)
                    withObject:Obj
                    waitUntilDone:NO];
    }

    - (void) MySelector:(id)Obj
    {
      NSLog(@"Data: %@", [Obj description]);
    }

    @end

    What is the value printed by the NSLog?

    enjoy.

    Ref: albertopasca.it


    FacebookTwitterDeliciousLinkedInGoogle BookmarksNetlogGoogle GmailMySpaceGoogle ReaderShare

    01
    feb

    NSString and retainCount memo:

    1
    2
    3
    4
    5
    6
    7
    8
        NSString *A = [[NSString alloc] init];
        NSLog(@"_A_RC: %i", [A retainCount]);

        NSString *B = [[NSString alloc] initWithFormat:@"AAA"];
        NSLog(@"_B_RC: %i", [B retainCount]);

        NSString *C = [[NSString alloc] initWithString:@"AAA"];
        NSLog(@"_C_RC: %i", [C retainCount]);
    1
    2
    3
    ...Test[3530:15203] _A_RC: -1  (ios < 5 = 2147483647)
    ...Test[3530:15203] _B_RC: 1
    ...Test[3530:15203] _C_RC: -1  (ios < 5 = 2147483647)

    Because your string is not in the heap, but is a constant. A NSString made from a constant NSString is identical to the original NSString.

    UINT_MAX (2147483647) -> http://it.wikipedia.org/wiki/2147483647

    Ref: albertopasca.it


    FacebookTwitterDeliciousLinkedInGoogle BookmarksNetlogGoogle GmailMySpaceGoogle ReaderShare

    , , ,

    Switch to our mobile site