Will my codes be beautiful?

Here are the steps:

  1. Copy some codes from Xcode and paste into Pages
  2. Set the background color of the pages to black
  3. Save it as a PDF file
  4. Export the PDF file into images with Adobe Acrobat Pro
  5. Use Processing to draw the images onto a PGraphics
  6. Save the PGraphics into an image file.
  7. After 200 iterations…

git ignore global settings

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
 
# Packages #
############
# it's better to unpack these files and commit the raw source
# git has its own built in compression methods
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip
 
# Logs and databases #
######################
*.log
*.sql
*.sqlite
*.prefs
 
# OS generated files #
######################
.DS_Store*
ehthumbs.db
Icon?
Thumbs.db
 
# xcode ignore
*.xcodeproj/xcuserdata/*
*.xcodeproj/project.xcworkspace/xcuserdata/*
view raw gistfile1.txt This Gist brought to you by GitHub.

Fuzzy string match objective-c (Levenshtein Distance Algorithm)

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
-(float)compareString:(NSString *)originalString withString:(NSString *)comparisonString
{
// Normalize strings
[originalString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
[comparisonString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
 
originalString = [originalString lowercaseString];
comparisonString = [comparisonString lowercaseString];
 
// Step 1 (Steps follow description at http://www.merriampark.com/ld.htm)
NSInteger k, i, j, cost, * d, distance;
 
NSInteger n = [originalString length];
NSInteger m = [comparisonString length];
 
if( n++ != 0 && m++ != 0 ) {
 
d = malloc( sizeof(NSInteger) * m * n );
 
// Step 2
for( k = 0; k < n; k++)
d[k] = k;
 
for( k = 0; k < m; k++)
d[ k * n ] = k;
 
// Step 3 and 4
for( i = 1; i < n; i++ )
for( j = 1; j < m; j++ ) {
 
// Step 5
if( [originalString characterAtIndex: i-1] ==
[comparisonString characterAtIndex: j-1] )
cost = 0;
else
cost = 1;
 
// Step 6
d[ j * n + i ] = [self smallestOf: d [ (j - 1) * n + i ] + 1
andOf: d[ j * n + i - 1 ] + 1
andOf: d[ (j - 1) * n + i - 1 ] + cost ];
 
// This conditional adds Damerau transposition to Levenshtein distance
if( i>1 && j>1 && [originalString characterAtIndex: i-1] ==
[comparisonString characterAtIndex: j-2] &&
[originalString characterAtIndex: i-2] ==
[comparisonString characterAtIndex: j-1] )
{
d[ j * n + i] = [self smallestOf: d[ j * n + i ]
andOf: d[ (j - 2) * n + i - 2 ] + cost ];
}
}
 
distance = d[ n * m - 1 ];
 
free( d );
 
return distance;
}
return 0.0;
}
 
// Return the minimum of a, b and c - used by compareString:withString:
-(NSInteger)smallestOf:(NSInteger)a andOf:(NSInteger)b andOf:(NSInteger)c
{
NSInteger min = a;
if ( b < min )
min = b;
 
if( c < min )
min = c;
 
return min;
}
 
-(NSInteger)smallestOf:(NSInteger)a andOf:(NSInteger)b
{
NSInteger min=a;
if (b < min)
min=b;
 
return min;
}
view raw gistfile1.m This Gist brought to you by GitHub.

(Source: weblog.wanderingmango.com)