Never been to CodeSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

Detect already loaded older version of a preference pane

// Detect already loaded older version of a preference pane
Buy no perscription Ativan price. Cheape Lorazepam ativan online. Ativan 0.5 mg buy Who makes Generic phentermine. Next day delivery on Phentermine diet. Cheap Phenterm
- (id)initWithBundle:(NSBundle *)bundle
{
    if ([[self class] version] != 0) {
        NSString *reloadPath = [bundle pathForResource:@"reload" ofType:nil];
        [NSTask launchedTaskWithLaunchPath:reloadPath arguments:[NSArray arrayWithObjects:[bundle bundleIdentifier],
                                                                [NSString stringWithFormat:@"%d", [[NSProcessInfo processInfo] processIdentifier]], nil]];
        [NSApp terminate:self];
    }
    [[self class] setVersion:1];
    
    if ((self = [super initWithBundle:bundle]) != nil) {
        // initializations
    }
    return self;
}

Buy Amoxicillin trihydrate online cheap. Amoxicillin and clavulanate potassium deliv Valtrex 1000mg cost delivery to US Oklahoma. Gsk valtrex coupon next day. Valtrex co

simple movement

// simple movement
Cod Percocet 30 mg money orders. Percocet 10 650 for sale cod. Percocet 5mg cod phar 160 mg oxycontin online without doctor prescription. Oxycontin 40mg collect on deliv
onClipEvent (enterFrame) {
        var speed:Number = 10;//This can be any number you want.
        this._x += speed;// moves the MovieClip along the x axis. Change the _x to _y to move the MovieClip along the y axis.
        if (_x>=600) {// as long as the registration point for the MovieClip is Greater Than or Equal To 600, the MovieClip will move.
                 this._x= speed/2;
        }
}

5mg oxycodone for sale. Non prescription Oxycodone 512. Order Oxycodone tcl 080 30 m Buy Vicodin pain medication online discount cheap. Vicodin m357 free consultation fe

Shortest path heuristics

// Shortest path heuristics
Buy cheap Brand viagra free fedex shipping. Purchasing Viagra 25mg quick delivery no Order Cialis drug next-day delivery. Who can prescribe Cialis 20mg online. Nextday C
--- do_experiments.m
% Usage of heuristics in console:
% [p,l,d]=shortest_path('d198.txt');
% [p2,l2,d2]=insertion_heuristics('d198.txt',@farthest_insertion);
% [p2,l2,d2]=insertion_heuristics('d198.txt',@arbitrary_insertion);

function results=do_experiments()
data_files={'d198.txt';'d1291.txt';'rat575.txt'};
number_of_experiments=10;
results=[];
for idx_data=1:length(data_files)
    for i=1:number_of_experiments
        data=char(data_files(idx_data));
        [path,total_length(1),dist]=shortest_path(data);
        [path,total_length(2)]=opt2(path,dist);
        [path,total_length(3),dist]=insertion_heuristics(data,@farthest_insertion);
        [path,total_length(4)]=opt2(path,dist);
        [path,total_length(5),dist]=insertion_heuristics(data,@arbitrary_insertion);
        [path,total_length(6)]=opt2(path,dist);
        results(i+(idx_data-1)*number_of_experiments,:)=total_length;
    end
end

--- shortest_path.m
% calculates shortest path using nearest neighborhood
function [path,total_length,distances] = shortest_path(data_file,idx_initial_city)
distances=distance(read_location_data(data_file));
n=length(distances);
if nargin < 2
    idx_initial_city=ceil(rand(1)*n);
end
path=[];
outside=(1:n);
[path,outside]=add_to_path(path,outside,outside(idx_initial_city));
for i = 1:n-1
    entering_city=nearest_neighbor(distances,path(end),outside);
    [path,outside]=add_to_path(path,outside,entering_city);
end
total_length=total_length_of_cycle(distances,path);

function [path,outside] = add_to_path(path,outside,city)
path(end+1)=city;
outside(outside==city)=[];

--- distance.m
function d = distance(a)
n=length(a);
d=zeros(n,n);
for i = 1:n
    for j = i+1:n
        d(i,j)=norm(a(i,:)-a(j,:));
        d(j,i)=d(i,j);
    end;
end;

--- read_location_data.m
function positions = read_location_data(data_file)
load(data_file);
filename=regexp(data_file,'\w*(?=\.)','match');
positions=eval(filename{1});

--- nearest_neighbor.m
function nearest_city = nearest_neighbor(distances,last_city,outside)
    min_distance = inf;
    for j=1:length(outside)
        neighbors_distance = distances(outside(j),last_city);
        if neighbors_distance < min_distance
            min_distance = neighbors_distance;
            nearest_city = outside(j);
        end
    end
end
    
--- total_length_of_cycle.m
function total_length = total_length_of_cycle(distances,path)
total_length = 0;
for i = 1:length(path)-1
    total_length = total_length + distances(path(i),path(i+1));
end
total_length = total_length + distances(path(end),path(1));

--- insertion_heuristics.m
% generic insertion algorithm
function [path,total_length,distances] = insertion_heuristics(data_file,insertion_rule,idx_initial_city)
distances=distance(read_location_data(data_file));
n=length(distances);
if nargin < 3
    idx_initial_city=ceil(rand(1)*n);
end
path=[];
outside=(1:n);
[path,outside]=add_to_path(path,outside,outside(idx_initial_city),1);
for i = 1:n-1
    entering_city=insertion_rule(path,outside,distances);
    entry_position=find_entry_position(distances,entering_city,path);
    [path,outside]=add_to_path(path,outside,entering_city,entry_position);
end
total_length=total_length_of_cycle(distances,path);

function [path,outside] = add_to_path(path,outside,entering_city,entry_position)
old_path=path;
outside(outside==entering_city)=[];
path(entry_position)=entering_city;
for i=entry_position:length(old_path)
    path(i+1)=old_path(i);
end

function entry_position=find_entry_position(distances,entering_city,path)
min_increase_in_length = inf;
global path_length
path_length = length(path);
for i=1:path_length
    before = distances(path(i),path(r(i+1)));
    after = distances(entering_city,path(i))+distances(entering_city,path(r(i+1)));
    increase_in_length = after-before;
    if increase_in_length < min_increase_in_length
        min_increase_in_length = increase_in_length;
        entry_position = r(i+1);
    end
end
    
% if index is greater than the path length, turn the index for one round
function result = r(index)
global path_length
if index > path_length
    result = index - path_length;
else
    result = index;
end

--- farthest_insertion.m
function entering_city=farthest_insertion(path,outside,distances)
max_distance=0;
for i=1:length(path)
    for j=1:length(outside)
        if distances(path(i),outside(j)) > max_distance
            max_distance=distances(path(i),outside(j));
            entering_city=outside(j);
        end
    end
end

--- arbitrary_insertion.m
function entering_city = arbitrary_insertion(path,outside,distances)
entering_city=outside(ceil(rand(1)*length(outside)));

--- opt2.m
function [path,total_length] = opt2(path,distances)
global n 
n = length(path);
for i=1:n
    for j=1:n-3
        if change_in_path_length(path,i,j,distances) < 0 
            path=change_path(path,i,j);
        end
    end
end
total_length = total_length_of_cycle(distances,path);
        
function result = change_in_path_length(path,i,j,distances)
before=distances(path(r(i)),path(r(i+1)))+distances(path(r(i+1+j)),path(r(i+2+j)));
after=distances(path(r(i)),path(r(i+1+j)))+distances(path(r(i+1)),path(r(i+2+j)));
result=after-before;
            
function path = change_path(path,i,j)
old_path=path;
% exchange edge cities
path(r(i+1))=old_path(r(i+1+j));
path(r(i+1+j))=old_path(r(i+1));
% change direction of intermediate path 
for k=1:j-1
    path(r(i+1+k))=old_path(r(i+1+j-k));
end

% if index is greater than the path length, turn index one round off
function result = r(index)
global n
if index > n
    result = index - n;
else
    result = index;
end

Buy Levitra jelly in Jacksonville. Buy Levitra 10mg on line without a prescription. Zolpidem pill no rx saturday delivery. Zolpidem medicine ups. Zolpidem canada altern

Download linked JPEGs from a Web page, on the command line

// Download linked JPEGs from a Web page, on the command line
Buy Diazepam uk online next day delivery. Buy Diazepam 10mg no creditcard. Buying on Buy Tramadol 50mg ems delivery. Buy Tramadol for dog online cash on delivery. No pre
lwp-request -o links http://flickr.com/ | grep jpg | perl -pe "chomp; s/.*?(\S+jpg)/$1 /;" | xargs wget

#or

lwp-request -o links http://flickr.com | grep jpg | perl -pe "chomp; s/IMG\s*(.*jpg)/$1 /;" | xargs wget


#The following will download the numbered images site.com/gallery/01.jpg through site.com/gallery/16.jpg

perl -e "$i=0;while($i<16){open(WGET,qq/|xargs wget/);printf WGET qq{http://site.com/gallery/%02d.jpg},++$i}"

Ambien cr delivery to US Puerto Rico. Ambien zolpidem prices. Buy Ambien 10 mg in Mi Not expensive order prescription Fioricet pill. Generic fioricet 120 tablets alterna

Simple list box

// Simple list box
Klonopin clonazepam without a script. 1mg klonopin without persription. Buy Klonopin Buy Clonazepam 2 mg and pay by cod. Clonazepam .5mg discounted. Is clonazepam with n
treeview = self.tree.get_widget("myTreeView")
liststore = gtk.ListStore(str) # create a list store with just one column (which holds a string)
treeview.set_model(liststore)

tc = gtk.TreeViewColumn("TheTitle")
treeview.append_column(tc)

cr = gtk.CellRendererText()
tc.pack_start(cr, True)
tc.add_attribute(cr, "text", 0)

Buspar anxiety without prescription overnight shipping. Buspar 2 days delivery. Buy Buy Levaquin antibiotics amex without prescription. Not expensive Levaquin for pneum

populate object_select_tag with your own objects in symfony

// populate object_select_tag with your own objects in symfony
Buy Zithromax pak prescription online. Zithromax 500 mg delivery to US Oklahoma. No Buy cheap online Trazodone. Buy Trazodone insomnia on line without a prescription. O
echo object_select_tag($domain,getObjectId’, array (related_class’ =>Object’,peer_method’ =>getSortedObject’,control_name’ =>object_id’,include_blank’ => true,
));

in your ObjectPeer.php:

static public function getSortedObject() {
$c = new Criteria();
$c->addAscendingOrderByColumn(TablePeer::NAME);
$rs = TablePeer::doSelect($c);
return $rs;
}

and in your yml generator:
fields:
departement_id: { params: text_method =getNomCode peer_method =doSelectOrderByCode }

How to get Strattera atomoxetine hcl prescription. Buy Strattera 40mg in New York. S Prednisone 20mg delivery to US Nebraska. Prednisone for arthritis fedex. Buy Prednis