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 fib( n ) { | |
var a = 1, b = 1; | |
for (i = 3; i <= n; i++) { | |
b = [a, a += b][0]; | |
} | |
return n == 0 ? 0 : a; | |
} |
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/env perl | |
# | |
use warnings; | |
use strict; | |
{ | |
print "How many items: "; | |
my $items = <STDIN>; | |
print "How many columns: "; | |
my $columns = <STDIN>; |
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> | |
#include <stdlib.h> | |
int main(int argc, char ** argv) { | |
printf("Where exactly " "(and by exactly i " | |
"clearly mean here) " | |
"is the syntax error?\n"); | |
exit(1); | |
} |
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
.file "test.c" | |
.section .debug_abbrev,"",@progbits | |
.Ldebug_abbrev0: | |
.section .debug_info,"",@progbits | |
.Ldebug_info0: | |
.section .debug_line,"",@progbits | |
.Ldebug_line0: | |
.text | |
.Ltext0: | |
.cfi_sections .debug_frame |
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
Eduardos-MacBook-Pro:~ earino$ nokogiri | |
rbenv: nokogiri: command not found | |
Eduardos-MacBook-Pro:~ earino$ gem install nokogiri | |
Building native extensions. This could take a while... | |
Successfully installed nokogiri-1.6.0 | |
1 gem installed | |
Installing ri documentation for nokogiri-1.6.0... | |
Installing RDoc documentation for nokogiri-1.6.0... | |
Eduardos-MacBook-Pro:~ earino$ rbenv rehash | |
Eduardos-MacBook-Pro:~ earino$ nokogiri |
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
s <- "some source text..." | |
cutpoints <-data.frame(start=text$start, end=text$end) | |
keeps <- data.frame(start=c(1, cutpoints$end+1), end=c(cutpoints$start-1, nchar(s))) | |
pieces <- apply(keeps, 1, function(x) substr(s, x[1], x[2])) | |
sliced_string <- paste(pieces, collapse="") |
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 <Rcpp.h> | |
#include <iostream> | |
using namespace Rcpp; | |
using namespace std; | |
. | |
// [[Rcpp::export]] | |
std::string string_slicer( std::string input, std::vector< int > start, std::vector< int > end) { | |
std::string working_copy = input; | |
for(std::vector<int>::size_type i = start.size() - 1; i != (std::vector<int>::size_type) -1; 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
sourceCpp('../src/string_slicer.cpp') | |
sliced_string <- string_slicer(s, cutpoints$start, cutpoints$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
#!/usr/bin/env perl | |
use warnings; | |
use strict; | |
use Data::Dumper; | |
my @records = (); | |
my $now = time(); | |
my $weeks = 604800 * 52; |
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
points = spark.textFile(...).map(parsePoint).cache() | |
w = numpy.random.ranf(size = D) # current separating plane | |
for i in range(ITERATIONS): | |
gradient = points.map( | |
lambda p: (1 / (1 + exp(-p.y*(w.dot(p.x)))) - 1) * p.y * p.x | |
).reduce(lambda a, b: a + b) | |
w -= gradient | |
print "Final separating plane: %s" % w |