lundi 30 décembre 2013

addSubview in UIAlertView deprecated in iOS7


There is a solution....

UIAlertView *alertView;

//a simple alert view with a simple message:
alertView = [[UIAlertView alloc]initWithTitle:nil message:@"My message here..." delegate:self cancelButtonTitle:nil otherButtonTitles:nil];
    

//a simple activity indicator:
UIActivityIndicatorView *activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
activityIndicator.frame= CGRectMake(50, 10, 37, 37);
activityIndicator.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleLeftMargin;    
[activityIndicator startAnimating];

//the magic line below,   
//we associate the activity indicator to the alert view: (addSubview is not used)
[alertView setValue:activityIndicator forKey:@"accessoryView"];
    
[alertView show];

mercredi 21 août 2013

[Knockout] How to define which properties are serialized in JSON ?


//we have a person structure, with a first name, a last name, 
//and a full name (computed field) :
function Person(first, last) {    
    this.first = ko.observable(first);    
    this.last = ko.observable(last);    
    this.full = ko.computed(function() {
        return this.first() + " " + this.last();
    }, this);
}


  • Solution 1
//we define which properties are serialized in JSON 
//(in this case, only full) and how they are serialized 
//(in this case, a simple string) :
Person.prototype.toJSON = function() {
   //only full :
   return ko.utils.unwrapObservable(this.full); // we return a string of the value
};
var person=new Person("a","b");
console.log(ko.toJSON(person)); 
// => it will generate : "a b"


  • Solution 2
//we define which properties are serialized in JSON 
//(in this case, first + last name):
Person.prototype.toJSON = function() {
    var copy = ko.toJS(this); //easy way to get a clean copy
    delete copy.full; //remove an extra property
    return copy; //return the copy to be serialized
};
var person=new Person("a","b");
console.log(ko.toJSON(person)); 
// => it will generate : {"first":"a", "last":"b"}



Source :http://www.knockmeout.net/2011/04/controlling-how-object-is-converted-to.html

mercredi 14 août 2013

[Python] convert timestamp -> datetime -> timestamp


#convert a date to a timestamp
def convert_to_timestamp(dt):
    return calendar.timegm(dt.utctimetuple())

#convert a timestamp to a datetime

def convert_to_date(timestamp_long):
    return datetime.datetime.utcfromtimestamp(timestamp_long)



mercredi 19 juin 2013

Bottle Restful - Links


http://nongraphical.com/2012/08/using-bottle-py-in-production/

http://www.marginhound.com/bottle-py-resources/

http://myadventuresincoding.wordpress.com/2011/01/02/creating-a-rest-api-in-python-using-bottle-and-mongodb/

http://mark-kirby.co.uk/2013/creating-a-true-rest-api/

http://gotofritz.net/blog/weekly-challenge/restful-python-api-bottle/

Find files under Linux containing CRLF


find . -not -type d -exec file "{}" ";" | grep CRLF

mardi 18 juin 2013

Test your web site with different browsers

Spoon.net Browser Sandbox provides a browser plugin that allows you to execute different browsers inside an isolated virtual environment and it is not necessary to install them. 

You can run Internet Explorer 6 under Windows 8 for example :)
The virtualized browsers run locally : you can test your web site hosted on your internal servers.


http://spoon.net/browsers

Online Text Comparator

http://www.text-compare.com

mercredi 22 mai 2013

Free software for Video Capture/Screencast

Hi all, 

I have found a powerful and free software : MSI Afterburner

You can download it here : http://event.msi.com/vga/afterburner/overview.htm

Even if you have not a MSI video card, you can use AfterBurner


Steps :

- Download it

- Run it

- Click on "Settings" :



- Go to "Video capture" tab :


- Choose your hotkey (which key to press to start/stop the recording) :



That's all ! :o)


Categories