This file contains 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 "rust_bindings/ruby/twittertext" | |
autolinker = Twittertext::Autolinker.new | |
puts autolinker.autolink "Just setting up my $TWTR or #TWTR or @twitter? Please visit https://twitter.com." | |
# prints | |
# Just setting up my <a href="https://twitter.com/search?q=%24TWTR" title="$TWTR" class="tweet-url cashtag">$TWTR</a> or | |
# <a href="https://twitter.com/search?q=%23TWTR" title="#TWTR" class="tweet-url hashtag">#TWTR</a> or | |
# @<a class="tweet-url username" href="https://twitter.com/twitter">twitter</a>? |
This file contains 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 "rust_bindings/ruby/twittertext" | |
autolinker = Twittertext::Autolinker.new | |
puts autolinker.autolink "Just setting up my $TWTR or #TWTR or @twitter? Please visit https://twiter.com." | |
# prints | |
# Just setting up my <a href="https://twitter.com/search?q=%24TWTR" title="$TWTR" class="tweet-url cashtag">$TWTR</a> or | |
# <a href="https://twitter.com/search?q=%23TWTR" title="#TWTR" class="tweet-url hashtag">#TWTR</a> or | |
# @<a class="tweet-url username" href="https://twitter.com/twitter">twitter</a>? |
This file contains 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
// inefficient, but correct | |
// | |
// See also: https://docs.rs/cesu8 | |
namespace std { | |
%typemap(jni) string "jbyteArray" | |
%typemap(in) string { | |
jsize length = jenv->GetArrayLength($input); | |
char* buf = (char *) jenv->GetPrimitiveArrayCritical($input, NULL); | |
// TODO: null/error check |
This file contains 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
$ rustc --print target-list | |
aarch64-apple-ios | |
aarch64-apple-tvos | |
aarch64-fuchsia | |
aarch64-linux-android | |
aarch64-pc-windows-msvc | |
aarch64-unknown-cloudabi | |
aarch64-unknown-freebsd | |
aarch64-unknown-hermit | |
aarch64-unknown-linux-gnu |
This file contains 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
#[derive(Debug, Clone, Copy)] | |
struct Coord { | |
x: f64, | |
y: f64, | |
} | |
impl Coord { | |
pub fn as_pair(&self) -> (String, String) { | |
(format!("{:.2}", self.x), format!("{:.2}", self.y)) | |
} |
This file contains 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
sayrer:mozilla sayrer$ time git clone https://github.com/mozilla/gecko-dev | |
Cloning into 'gecko-dev'... | |
remote: Enumerating objects: 248, done. | |
remote: Counting objects: 100% (248/248), done. | |
remote: Compressing objects: 100% (195/195), done. | |
remote: Total 7936670 (delta 75), reused 102 (delta 49), pack-reused 7936422 | |
Receiving objects: 100% (7936670/7936670), 4.39 GiB | 20.08 MiB/s, done. | |
Resolving deltas: 100% (6322848/6322848), done. | |
Checking out files: 100% (275725/275725), done. |
This file has been truncated, but you can view the full file.
This file contains 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
Date/Time: 2019-03-12 16:57:26 -0700 | |
End time: 2019-03-12 16:57:30 -0700 | |
OS Version: Mac OS X 10.14.3 (Build 18D109) | |
Architecture: x86_64h | |
Report Version: 27 | |
Data Source: Stackshots | |
Shared Cache: 0x17a96000 06978416-1BF5-38C1-8C4F-2D1EDBFD2A45 | |
Command: Google Chrome |
This file contains 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
from https://github.com/spullara/interviewcode/commit/7990f661990837ad9ba8b42dbe34408279a22c5e | |
Roberts-MacBook-Pro:interviewcodecpp sayrer$ ./main | |
Starting | |
Running benchmark | |
483 ns/op | |
456 ns/op | |
452 ns/op | |
452 ns/op | |
450 ns/op |
This file contains 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
Running tweet entity replacement with Tendril: | |
https://github.com/sayrer/interviewcode/commit/d312aba609e31b28ad7968502853ad82ef6b394b | |
test rendertest::bench_replacement ... bench: 955 ns/iter (+/- 37) | |
test rendertest::bench_replacement_chars ... bench: 1,037 ns/iter (+/- 161) | |
test rendertest::bench_replacement_chars2 ... bench: 558 ns/iter (+/- 36) | |
test rendertest::bench_replacement_chars_stack ... bench: 445 ns/iter (+/- 27) | |
test rendertest::bench_replacement_chars_stack_tendril ... bench: 793 ns/iter (+/- 116) |
This file contains 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
#[derive(Clone, PartialEq, Hash, Eq)] | |
pub struct Entity { | |
start: usize, | |
end: usize, | |
html: String | |
} | |
impl Ord for Entity { | |
fn cmp(&self, other: &Self) -> Ordering { | |
self.start.cmp(&other.start) |