Tag Archive for create

Create a directory recursively

mkdir -p /Users/Shared/Desktop/homer/marge/bart/lisa/maggie/snowball2

#or, in a .bash_profile
alias mkdir="mkdir -p "

source

create new files

# whatever arguments are given at the command line are
# taken to be the names for new text files,
# which are then created:

open OUT, ">$ARGV[0]" or die $!;
seek OUT,0,0 and print OUT " ";
close OUT;

source

Remove duplicate lines from a text file with Perl

#!/usr/bin/perl -w
use strict;
my $origfile = shift;
my $outfile  = "no_dupes_" . $origfile;
my %hTmp;

open (IN, "<$origfile")  or die "Couldn't open input file: $!";
open (OUT, ">$outfile") or die "Couldn't open output file: $!";

while (my $sLine = <IN>) {
next if $sLine =~ m/^s*$/;  #remove empty lines. Without this, still destroys empty lines except for the first one.
$sLine=~s/^s+//;            #strip leading/trailing whitespace
$sLine=~s/s+$//;
print OUT qq{$sLine
} unless ($hTmp{$sLine}++);
}
close OUT;
close IN;

source

Make a list of JPEGs into a slide show

#! /usr/bin/perl -w
use strict;

############################################################
#                                                          #
#                                                          #
#                                                          #
#                  NOAH SUSSMAN                            #
#                                                          #
#                  showserial.pl                           #
#                                                          #
#                Created 10/8/3 at 1.41am                  #
#                                                          #
#    Show jpegs one-per-page on a series of hyperlinked    #
#    web pages.  Purpose is to provide a good _linear_     #
#    viewing mechanism for jpegs on the palm.              #
#    Adapted from showsm.pl                                #
#                                                          #
#                                                          #
############################################################

my @images;

while (<*.jp*>) {
push @images, $_;  #read image filenames into a list
}

shift @images;  #first image is never the subject of  a "next" hyperlink

while (<*.jp*>) {  #regex captures any filename with extension beginning "JP"

my $next_file;
$next_file = $images[0]; #read the next filename into $next_file
shift @images; #manually discard the value we just read into $next_file

my $out="$_";
$out =~ s/jpeg/html/gio;
open OUT, ">$out" or die "Cannot open $out for write :$!";

if ($next_file){
#print $next_file;
$next_file =~ s/jpeg/html/gio;
print OUT "<a href="$next_file">";
}

print OUT "<html><head><title>$_</title></head><body>
";
print OUT "<img src="$_" >
";  #an image tag points to each file name
print OUT "</body></html>";

if ($next_file){
print OUT "</a>";
}
}

source

Rake Migrate Migrations Create Table Example

	      class AddEntriesTable < ActiveRecord::Migration
def self.up
create_table :entries do |table|
table.column :title, :string
table.column :content, :text
table.column  :created_at, :datetime
end
end

def self.down
drop_table :entries
end
end

source

php create function

class Obj
{
public $test;

function cf()
{
$this->test = create_function( '', 'echo "Testing";' );
}
}

$o = new Obj;

$o->cf();

$o->{$test};

source

Create JGraph Cell

DefaultGraphCell cell = new DefaultGraphCell(name);
GraphConstants.setBorderColor(cell.getAttributes(), Color.black);
GraphConstants.setBounds(cell.getAttributes(), new Rectangle2D.Double(posx, posy, 100, 20));
DefaultPort port = new DefaultPort();
cell.add(port);
graph.getGraphLayoutCache().insert(cell);

source