#!/usr/bin/env ruby
server_url = ""
username = ""
passwd = ""
require 'net/ftp'
ftp=Net::FTP.new
ftp.connect(server_url,21)
ftp.login(username,passwd)
ftp.chdir("faraim-ios")
# ftp.getbinaryfile(filename)
ftp.list { |item|
puts item
}
ftp.close
Saturday, March 16, 2013
connect to an ftp server with a ruby script
Wednesday, March 13, 2013
get dimensions of a ruby image using the Dimensions gem
#!/usr/bin/env ruby
require 'dimensions'
images = %w(31.SpecialAirspace.png 31.SpecialAirspace@2x.png)
images.each { |image|
puts image
size = Dimensions.dimensions(image)
w = Dimensions.width(image)
h = Dimensions.height(image)
p size
p w
p h
}
Sunday, March 10, 2013
.command file to run scss watch
double-click to open up a watch command in a new terminal window.
for an example, see:
for an example, see:
/Users/smr/current_projects/oeg-ios/scss/oeg-i/oegi-sass-compile.command
cd /Users/smr/current_projects/oeg-ios/scss/oeg-i/; sass --watch oeg.scss:oeg.css --compass --no-cache
customize google code prettify syntax highlighting styles
create a css class that defines your desired colors, e.g.:
/Users/smr/Sites/prettify/google-code-prettify/xcode.css
/* Pretty printing styles. Used with prettify.js. */
/* SPAN elements with the classes below are added by prettyprint. */
.pln { color: #000 } /* plain text */
@media screen {
.str { color: #C51A16 } /* string content */
.kwd { color: #AA0D91 } /* a keyword */
.com { color: #007400 } /* a comment */
.typ { color: #5B2699 } /* a type name */
.lit { color: #066 } /* a literal value */
/* punctuation, lisp open bracket, lisp close bracket */
.pun, .opn, .clo { color: #000 }
.tag { color: #008 } /* a markup tag name */
.atn { color: #606 } /* a markup attribute name */
.atv { color: #080 } /* a markup attribute value */
.dec, .var { color: #606 } /* a declaration; a variable name */
.fun { color: #26474B } /* a function name */
}
/* Use higher contrast and text-weight for printable form. */
@media print, projection {
.str { color: #060 }
.kwd { color: #006; font-weight: bold }
.com { color: #600; font-style: italic }
.typ { color: #404; font-weight: bold }
.lit { color: #044 }
.pun, .opn, .clo { color: #440 }
.tag { color: #006; font-weight: bold }
.atn { color: #404 }
.atv { color: #060 }
}
/* Put a border around prettyprinted code snippets. */
pre.prettyprint { padding: 2px; border: 1px solid #888 }
/* Specify class=linenums on a pre to get line numbering */
ol.linenums { margin-top: 0; margin-bottom: 0 } /* IE indents via margin-left */
li.L0,
li.L1,
li.L2,
li.L3,
li.L5,
li.L6,
li.L7,
li.L8 { list-style-type: none }
/* Alternate shading for lines */
li.L1,
li.L3,
li.L5,
li.L7,
li.L9 { background: #eee }
Saturday, March 9, 2013
UIWebview and the display of 2x retina images
see:
/Users/smr/current_projects/oeg-ios/work/2x-bg-image-workthrough/
Out of the box, UIWebView doesn't automatically use 2x images for retina displays (as is the ase when doing iOS SDK programming), so you have to fudge it.
Three different approaches to this problem are discussed here:
http://spritebandits.wordpress.com/2012/01/17/using-uiwebview-with-retina-displays/
The problem looks like this (note the blurry image):
this particular example uses a div with a background url to display an image. red and green borders are added just to show that the media query version is being used on retina displays.
the 1x image is taken care of with css like:
to handle the 2x version, use a media query that targets retina displays:
the fix looks like this:
note that the
/Users/smr/current_projects/oeg-ios/work/2x-bg-image-workthrough/
Out of the box, UIWebView doesn't automatically use 2x images for retina displays (as is the ase when doing iOS SDK programming), so you have to fudge it.
Three different approaches to this problem are discussed here:
http://spritebandits.wordpress.com/2012/01/17/using-uiwebview-with-retina-displays/
The problem looks like this (note the blurry image):
![]() |
| blurry 1x image being used on a retina device |
this particular example uses a div with a background url to display an image. red and green borders are added just to show that the media query version is being used on retina displays.
the 1x image is taken care of with css like:
.header-bg-image {
/*non-retina and shared values*/
width: 174px;
height: 65px;
margin-right: 10px;
background: url('OEG-phone-pvt-menu-header.png');
-webkit-background-size: 174px 65px;
float: right;
border: 1px solid green;
}
to handle the 2x version, use a media query that targets retina displays:
@media screen and (-webkit-device-pixel-ratio: 2) {
.header-bg-image {
background: url('OEG-phone-pvt-menu-header@2x.png');
border: 1px solid red;
}
}
the fix looks like this:
![]() |
| 2x image being used after implementing a media query |
note that the
-webkit-background-size: 174px 65px; must be present or the image gets rendered funkily:![]() |
| forgot the -webkit-background-size, so no bueno |
Thursday, March 7, 2013
bootstrap cdn
<link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap.css" rel="stylesheet"> <link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap.min.css" rel="stylesheet"> <link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css" rel="stylesheet"> <script src="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/js/bootstrap.min.js"></script>
Wednesday, March 6, 2013
find-tags.pl perl script to dump the tags used in an xml file
creates an html page.
~/bin/find-tags.pl
~/bin/find-tags.pl
#!/usr/bin/perl -w
#usage:
#find-tags.pl *.xml
use strict;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
#
# global variables
#
my %elements;
my @element_stack; # remembers element names
my $in_intset; # flag: are we in the internal subset?
my $q = new CGI();
my @filenames;
# initialize the parser
#
use XML::Parser::PerlSAX;
my $parser = XML::Parser::PerlSAX->new( Handler => MyHandler->new( ) );
foreach my $infile (@ARGV)
{
print '$infile = ' . $infile . "\n";
push @filenames, $infile;
$parser->parse( Source => {SystemId => $infile} );
}
# use bootsrap served from a cdn
my $html = q{
<!DOCTYPE html>
<html>
<head>
<title>find-tags</title>
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container">
};
$html .= $q->h1("find-tags.pl");
$html .= $q->h2("found these tags:");
$html .= $q->start_ul;
for (sort {lc $a cmp lc $b} keys %elements)
{
$html .= $q->li({-style=>'padding-top:5px;padding-bottom:5px;'}, qq{<code>$_</code> <span class="badge">$elements{$_}</span>} );
}
$html .= $q->end_ul;
$html .= $q->h2("while searching these files:");
$html .= $q->start_ul;
foreach my $file (@filenames)
{
$html .= $q->li("$file");
}
$html .= $q->end_ul;
$html .= q{
</div>
</body>
</html>
};
my $html_filename = "/tmp/find-tags.html";
open(OUTFILE, "> $html_filename") or die "can't open $html_filename: $!";
print OUTFILE $html;
close OUTFILE;
system("open", "$html_filename");
exit;
###
### Document Handler Package
###
package MyHandler;
#
# initialize the handler package
#
sub new {
my $type = shift;
return bless {}, $type;
}
#
# handle a start-of-element event: output start tag and attributes
#
sub start_element {
my( $self, $properties ) = @_;
# note: the hash %{$properties} will lose attribute order
#example porperty hash:
# {
# 'Attributes' => {
# 'align' => 'left',
# 'valign' => 'middle'
# },
# 'Name' => 'entry'
# }
# remember the name by pushing onto the stack
push( @element_stack, $properties->{'Name'} );
$elements{$properties->{'Name'}}++;
}
Subscribe to:
Comments (Atom)


