Currently supports:
- Insertion (insert)
- Search (search, node)
- Printing (to_s)
git clone at:
http://github.com/giancarlo/algorithms.git
Please don't interrupt. Just sit back and listen.
http://github.com/giancarlo/algorithms.git
PJF.replace("h2");
PJF.replace("#topmenu UL > LI");
PJF.replace("h1", { size: 20, color: [255, 0, 0] });
source /opt/intel/Compiler/11.0/069/bin/iccvars.sh ia32
icc -v
icc
with a configure script use ./configure CC=icc
Kernel.block_given?
will tell you if a block was passed.
def test
a = 42
yield(a) if block_given?
end
yield
or Proc.call
like this:
def test(&block)
a = 42
yield(a) # or block.call(a,b)
end
yield
calls and passes the arguments to the block.block.arity
will tell you the number of arguments a block can accept
def recursive_function(&block)
# Do stuff
recursive_function(&block)
# pass to other functions accepting blocks
10.times &block # will run block 10 times
end
def bl(&block)
yield
end
def test
bl { return }
puts "Hello" # this will not be executed.
end
break
to return a value inside a block and stop iterating.
def bl(&block)
(0..10).each &block
end
def test
# This block will stop iterating at 5 and return true.
bl { |x| (break true) if (x == 5); false }
end
<script language='javascript' src='http://www.url.com/Scripts/shCore.js'></script>
<script language='javascript'>
window.onload = function() {
dp.SyntaxHighlighter.ClipboardSwf = 'http://www.url.com/Scripts/clipboard.swf';
dp.SyntaxHighlighter.BloggerMode();
dp.SyntaxHighlighter.HighlightAll('code');
}
</script>
<link href='http://www.url.com/Styles/SyntaxHighlighter.css' rel='stylesheet' type='text/css'/>
<pre name='code' class='language'>
code;
</pre>
<script language='javascript' src='http://www.url.com/Scripts/shBrushXml.js'></script>
.icon-name {
display: block; height: 32px; width: 32px;
background: transparent url(icon.png) -(x)px -(y)px no-repeat;
cursor: pointer;
}
Kernel.trap('INT') { code }
hsetroot -fill ~/Desktop/desktop.jpg &
xcompmgr &
rxvt &
docker &
URxvt*depth: 32
urxvt*background: rgba:0000/0000/0000/cccc
URxvt*background: rgba:0000/0000/0000/cccc
URxvt*foreground: green
set tabstop=2
:wq
Ctrl+Q
:tabe file # Opens File
:tabn # goes to next tab
:tabp # goes to previous tab
:q # closes current tab
gt # will take you to the next tab
gT # will take you to the previous tab
Ctrl+N Ctrl+P
:grep args
:make
set background=dark # if your console background is dark..
syntax on
set nu
split
vsplit # Vertical Split
Ctrl+W+(direction)
open file
close
/regex
:number
*
VALUE obj;
obj = rb_obj_alloc(Class); // Allocate space and create new instance
rb_obj_call_init(obj, 0, 0); // We call the initialize method for the object
VALUE rb_define_class("name", parent_class);
VALUE rb_define_class_under(module_or_class, "name", parent_class);
rb_define_method(class, "name", c_function, argc)
VALUE function( int argc, VALUE* args, VALUE instance );
VALUE function( VALUE instance, VALUE array_of_arguments);
rb_iv_get(instance, "variable");
rb_iv_set(instance, "variable", new_value);
rb_raise(exception_object, string_message);
rb_eArgError
rb_eEOFError
rb_eException
rb_eFatal
rb_eFloatDomainError
rb_eIndexError
rb_eInterrupt
rb_eIOError
rb_eKeyError
rb_eLoadError
rb_eLocalJumpError
rb_eNameError
rb_eNoMemError
rb_eNoMethodError
rb_eNotImpError
rb_eRangeError
rb_eRegexpError
rb_eRuntimeError
rb_eScriptError
rb_eSecurityError
rb_eSignal
rb_eStandardError
rb_eStopIteration
rb_eSyntaxError
rb_eSysStackError
rb_eSystemCallError
rb_eSystemExit
rb_eThreadError
rb_eTypeError
rb_eZeroDivError
$rss = simplexml_load_file("rss feed url");
foreach ($rss->channel->item as $k)
echo $k->title . "\n";
$rss = simplexml_load_file("blog rss url!");
foreach ($rss->channel->item as $k)
$rss_list .= "<li>" . $k->title . "</li>\n";
$index_rss = "<ul>$rss_list</ul>";
rb_yield(Qnil);
rb_block_given_p();
#define RBASIC(obj) (R_CAST(RBasic)(obj))
#define ROBJECT(obj) (R_CAST(RObject)(obj))
#define RCLASS(obj) (R_CAST(RClass)(obj))
#define RMODULE(obj) RCLASS(obj)
#define RFLOAT(obj) (R_CAST(RFloat)(obj))
#define RSTRING(obj) (R_CAST(RString)(obj))
#define RREGEXP(obj) (R_CAST(RRegexp)(obj))
#define RARRAY(obj) (R_CAST(RArray)(obj))
#define RHASH(obj) (R_CAST(RHash)(obj))
#define RDATA(obj) (R_CAST(RData)(obj))
#define RSTRUCT(obj) (R_CAST(RStruct)(obj))
#define RBIGNUM(obj) (R_CAST(RBignum)(obj))
#define RFILE(obj) (R_CAST(RFile)(obj))
#define RRATIONAL(obj) (R_CAST(RRational)(obj))
#define RCOMPLEX(obj) (R_CAST(RComplex)(obj))
struct RFloat {
struct RBasic basic;
double float_value;
};
struct RBignum {
struct RBasic basic;
union {
struct {
long len;
BDIGIT *digits;
} heap;
BDIGIT ary[RBIGNUM_EMBED_LEN_MAX];
} as;
};
struct RBasic basic;
union {
struct {
long len;
char *ptr;
union {
long capa;
VALUE shared;
} aux;
} heap;
char ary[RSTRING_EMBED_LEN_MAX];
} as;
RFLOAT(ruby_value)->double_value;
10 in Ruby => (10 >> 1) in C
10 in C => (10 << 1 | 1) in Ruby
-10 in Ruby => (10 >> 1) in C
-10 in C => (10 >> 1 | 1) in Ruby (0xffffffed)
class A
{
function __construct()
{
new B;
}
}
class B extends A
{
}
new A;
require 'net/http'
require 'uri'
class XHTML
VALIDATOR_URL = 'http://validator.w3.org/check'
XHTML_STRICT = 'XHTML 1.0 Strict'
XHTML_TRANSITIONAL = 'XHTML 1.0 Transitional'
XHTML_FRAMESET = 'XHTML 1.0 Frameset'
# Returns validation messages
def XHTML.validate(what, xhtml_version=XHTML_STRICT)
post_data = {
'fragment' => what,
'doctype' => xhtml_version
}
r = Net::HTTP.post_form(URI.parse(VALIDATOR_URL), post_data)
return r.body
end
end
attr_reader :a # Generates a reader/get function:
#def a
# @a
#end
attr_writer :a # Generates a writer/set function
#def a= (value)
# @a = value
#end
attr_accessor :a # Generates Both get/set functions
class Module
def custom_accessor(*symbols)
symbols.each do |symbol|
class_eval "
# Here we would insert the code that we want to generate.
"
end
end
end
custom_accessor :accessor
ENV # Hash of environment variables
STDIN # IO stream for standard input
STDOUT # IO stream for standard output, most cases the console
STDERR # IO stream for standard error output
RUBY_VERSION # String containing current ruby version
RUBY_RELEASE_DATE # String containing the date in which ruby was compiled
RUBY_PLATFORM # String containing the platform and compiler used to build ruby
ARGV # Array of arguments used to run the ruby file. ARGV[0] is the first argument, not the name of the file.
$: # Ruby Include Path
$> # STDOUT
$. # Current Line
$! # Latest error message
$@ # location of error
$_ # string last read by gets
$. # line number last read by interpreter
$& # string last matched by regexp
$~ # the last regexp match, as an array of subexpressions
$n # the nth subexpression in the last match (same as $~[n])
$= # case-insensitivity flag
$/ # input record separator
$\ # output record separator
$0 # the name of the ruby script file
$* # the command line arguments
$$ # interpreter's process ID
$? # exit status of last executed child process
$SAFE # safe level (0-4)
$" # Loaded modules, extensions (also $LOADED_FEATURES)
ruby extconf.rb --with-mysql-include=/path/to/mysql/include --with-mysql-lib=/path/to/libs
nmake
ruby test.rb [hostname [user [passwd [dbname [port [socket [flag]]]]]]]
char* RSTRING_PTR(VALUE); /* Ruby String to char* */
int RSTRING_LEN(VALUE); /* String length */
char* StringValuePtr(VALUE); /* Returns string representation of any object */
RSTRING StringValue(VALUE); /* Returns Ruby string representation of any object */
int NUM2INT(VALUE); /* Number to Int */
double NUM2DBL(VALUE); /* Double to Int */
VALUE* RARRAY_PTR(RARRAY); /*Returns the pointer to values of a Ruby Array */
int RARRAY_LEN(RARRAY); /* Returns length of Array */
/* Integer to Ruby Number*/
INT2NUM(number);
UINT2NUM(number);
DOUBLE2NUM(double); /* Or rb_float_new(double) */
RSTRING rb_str_new(char*, len); /* Returns ruby string from char* and length*/
RSTRING rb_str_new2(char*); /* Returns ruby string from null terminated char* */
VALUE array = rb_ary_new(); /* Create the array */
rb_ary_push(array, VALUE); /* Push data into the array */
VALUE hash = rb_hash_new();
rb_hash_aset(hash, VALUE key, VALUE);
rb_type(VALUE);
#define T_NONE RUBY_T_NONE
#define T_NIL RUBY_T_NIL
#define T_OBJECT RUBY_T_OBJECT
#define T_CLASS RUBY_T_CLASS
#define T_ICLASS RUBY_T_ICLASS
#define T_MODULE RUBY_T_MODULE
#define T_FLOAT RUBY_T_FLOAT
#define T_STRING RUBY_T_STRING
#define T_REGEXP RUBY_T_REGEXP
#define T_ARRAY RUBY_T_ARRAY
#define T_HASH RUBY_T_HASH
#define T_STRUCT RUBY_T_STRUCT
#define T_BIGNUM RUBY_T_BIGNUM
#define T_FILE RUBY_T_FILE
#define T_FIXNUM RUBY_T_FIXNUM
#define T_TRUE RUBY_T_TRUE
#define T_FALSE RUBY_T_FALSE
#define T_DATA RUBY_T_DATA
#define T_MATCH RUBY_T_MATCH
#define T_SYMBOL RUBY_T_SYMBOL
#define T_RATIONAL RUBY_T_RATIONAL
#define T_COMPLEX RUBY_T_COMPLEX
#define T_VALUES RUBY_T_VALUES
#define T_UNDEF RUBY_T_UNDEF
#define T_NODE RUBY_T_NODE
#define T_MASK RUBY_T_MASK
rb_hash_foreach(hash, iterator_c_function, extra_value);
int iterator(VALUE key, VALUE value, VALUE extra);
VALUE module = rb_define_module("name");
rb_define_method_function(module, "name", c_function, argc);
VALUE c_function(VALUE module, VALUE arg);
rb_define_const(module_or_class, "NAME", value);