This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
puts | |
File.open(ARGV[0]).each do |line| | |
line = line.split | |
if line[0] == "IBOutlet" | |
puts "[#{line[2].tr('*;','')} release];" | |
elsif line[1] and line[1].include? "*" | |
puts "[#{line[1].tr('*;','')} release];" | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Javascript Benchmark Declaring len inside and outside of a for loop | |
// Populate array with 0..100 | |
var arr = [] | |
for (var i=0; i<1e3; ++i) { arr[i] = i; } | |
// Declare len outside of the for | |
function outfor(a) { | |
var len = a.length; | |
for (var i=0; i<len; ++i); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'hpricot' # hpricot-0.6.164 | |
html = <<END | |
<html><head></head><body><table> | |
<tr><td>R0C0</td><td>R0C1</td><td>R0C2</td><td>R0C3</td></tr> | |
<tr><td>R1C0</td><td>R1C1</td><td>R1C2</td><td>R1C3</td></tr> | |
<tr><td>R2C0</td><td>R2C1</td><td>R2C2</td><td>R2C3</td></tr> | |
</table></body></html> | |
END |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# DATA is a global that is actually a | |
# File object containing the data | |
# after __END__ in the current | |
# script file. WHOA! | |
puts DATA.read | |
__END__ | |
I can put anything I want | |
after the __END__ symbol | |
and access it with the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int str_cmp( char *str1, char *str2 ) { | |
if ( !*str1 && !*str2 ) | |
return 0; | |
char a = *str1, b = *str2; | |
if( a >= 'a' && a <= 'z' ) | |
a -= 32; | |
if( b >= 'a' && b <= 'z' ) | |
b -= 32; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Strip Similarities between two strings | |
module Kernel | |
# | |
# strip_similiar | |
# Strips the similiarities at the start and end of each | |
# of the given strings, returning a list of both of the | |
# stripped strings. | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Function: allData(node) | |
// Concatenate all the text data of a node's children. | |
// | |
function allData(node) { | |
var data = ""; | |
if (node && node.firstChild) { | |
node = node.firstChild; | |
if (node.data) { data += node.data; } | |
while (node = node.nextSibling) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Benchmarking String Concatenation Comparing | |
// 1. Array.join | |
// 2. String concatenation with '+' | |
// Test Functions | |
function test_join(content) { return ['output.push(', content, ');'].join(''); }; | |
function test_str_concat(content) { return 'output.push(' + content + ');'; }; | |
// Test Strings | |
var SHORT_STRING = 'test'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ways to execute a shell script in Ruby | |
# Example Script - Joseph Pecoraro | |
cmd = "echo 'hi'" # Sample string that can be used | |
# 1. Kernel#` - commonly called backticks - `cmd` | |
# This is like many other languages, including bash, PHP, and Perl | |
# Synchronous (blocking) | |
# Returns the output of the shell command | |
# Docs: http://ruby-doc.org/core/classes/Kernel.html#M001111 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
void str_squeeze(char *s) { | |
int i, j; | |
char last = '\0'; | |
for ( i = j = 0; s[i]; last = s[i++] ) | |
if ( s[i] != last ) | |
s[j++] = s[i]; | |
s[j] = '\0'; | |
} |