vagrant simple example

# -*- mode: ruby -*-
# vi: set ft=ruby :

# Vagrantfile API/syntax version. Don’t touch unless you know what you’re doing!
VAGRANTFILE_API_VERSION = “2”

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.provider “virtualbox” do |v|
v.memory = 1024
v.cpus = 1
end
config.vm.define “prod” do |prod_config|
prod_config.vm.box = “jamnplayer”
prod_config.vm.network “forwarded_port”, guest: 8080, host: 8081
prod_config.vm.network “forwarded_port”, guest: 5000, host: 5001
prod_config.vm.network “forwarded_port”, guest: 22, host: 2200, auto_correct: false, id: “ssh”
prod_config.vm.host_name = “prod”
end
end

======

# -*- mode: ruby -*-
# vi: set ft=ruby :

# Vagrantfile API/syntax version. Don’t touch unless you know what you’re doing!
VAGRANTFILE_API_VERSION = “2”

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.provider “virtualbox” do |v|
v.memory = 2048
v.cpus = 1
end
config.vm.define “default” do |default_config|
default_config.vm.box = “ubuntu-14.04”
default_config.vm.network “forwarded_port”, guest: 6543, host: 6543
default_config.vm.network “forwarded_port”, guest: 8080, host: 8080
default_config.vm.network “forwarded_port”, guest: 5000, host: 5000
default_config.vm.network “forwarded_port”, guest: 22, host: 2222, auto_correct: false, id: “ssh”
default_config.vm.host_name = “default”
end
end

the virtualbox system ubuntu bit maybe wrong

I know at least 2 ways. Open a terminal and type:

uname -a

Result for 32-bit Ubuntu:

Linux discworld 2.6.38-8-generic #42-Ubuntu SMP Mon Apr 11 03:31:50 UTC 2011 i686 i686 i386 GNU/Linux

whereas the 64-bit Ubuntu will show:

Linux discworld 2.6.38-8-generic #42-Ubuntu SMP Mon Apr 11 03:31:50 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux

or

file /sbin/init

Result for 32-bit Ubuntu:

/sbin/init: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, stripped

whereas for the 64-bit version it would look like:

/sbin/init: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, stripped

python property, getter, setter

Try this: Python Property

The sample code is:

class C(object):
def __init__(self):
self._x = None

@property
def x(self):
“””I’m the ‘x’ property.”””
print “getter of x called”
return self._x

@x.setter
def x(self, value):
print “setter of x called”
self._x = value

@x.deleter
def x(self):
print “deleter of x called”
del self._x

[ios] filter music from ios by MPMediaQuery

MPMediaQuery *songQuery = [MPMediaQuery artistsQuery];
// OR
MPMediaQuery *songQuery = [MPMediaQuery songsQuery];

// local only
[songQuery addFilterPredicate:[MPMediaPropertyPredicate predicateWithValue:[NSNumber numberWithBool:NO] forProperty:MPMediaItemPropertyIsCloudItem]];

NSArray *songs = [songQuery items];

And u will retrieve a list … but music video is still here…
becoz music video is 2049 … ok u see

enum {
// audio
MPMediaTypeMusic = 1 << 0, MPMediaTypePodcast = 1 << 1, MPMediaTypeAudioBook = 1 << 2, MPMediaTypeAudioITunesU = 1 << 3, // available in iOS 5.0 MPMediaTypeAnyAudio = 0x00ff, // video (available in iOS 5.0) MPMediaTypeMovie = 1 << 8, MPMediaTypeTVShow = 1 << 9, MPMediaTypeVideoPodcast = 1 << 10, MPMediaTypeMusicVideo = 1 << 11, MPMediaTypeVideoITunesU = 1 << 12, MPMediaTypeAnyVideo = 0xff00, MPMediaTypeAny = ~0 }; typedef NSInteger MPMediaType; tht's it: MPMediaTypeMusic: 1 MPMediaTypePodcast: 2 MPMediaTypeAudioBook: 4 MPMediaTypeAudioITunesU: 8 (iOS 5) MPMediaTypeAnyAudio: 255 MPMediaTypeMovie: 256 MPMediaTypeTVShow: 512 MPMediaTypeVideoPodcast: 1024 MPMediaTypeMusicVideo: 2048 MPMediaTypeVideoITunesU: 4096 MPMediaTypeAnyVideo: 65280 2049 is MPMediaTypeMusicVideo + MPMediaTypeMusic MPMediaQuery *songQuery = [MPMediaQuery artistsQuery]; OR MPMediaQuery *songQuery = [MPMediaQuery songsQuery]; OR [songQuery addFilterPredicate:[MPMediaPropertyPredicate predicateWithValue:[NSNumber numberWithInteger:MPMediaTypeMusic] forProperty:MPMediaItemPropertyMediaType]]; even add comparisonType:MPMediaPredicateComparisonEqualTo 3 methods no work ... it want mediaType contain 1 and 2049 is still here method : filter it: NSArray *songs = [songQuery items]; NSMutableArray *finalSongs = [NSMutableArray array]; [songs enumerateObjectsUsingBlock:^(MPMediaItem *song, NSUInteger idx, BOOL *stop) { NSInteger mediaValue = [[song valueForProperty:MPMediaItemPropertyMediaType] integerValue]; if (mediaValue == 1) [finalSongs addObject:song]; }];

AFNetworking using manager to eat @”text/plain”

make AFHTTPRequestOperationManager can eat text/plain (or other content-type)
rmb re-init serializer for it…
the default one like JSON very much … but i m not doing JSON …

AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.responseSerializer = [AFHTTPResponseSerializer serializer];
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@”text/plain”];

rmb add “file://” when using multipart form file
NSString *file = [[NSString alloc] initWithFormat: @”file://{file_address}];

import vamp into ios

put all library into a Vendors/VampPlugin folder
add -lstdc into build settings, other linker flags
edit the to “library” if needed
(dun add the simple host first)
comment the main a gXXx.c , since it crash the “main”
compile and goodbye